This documentation is automatically generated by online-judge-tools/verification-helper
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/1/ITP1_1_A"
// #define PROBLEM "https://codeforces.com/contest/2014/problem/H"
/*
* Codeforces Round 974 (Div. 3) H. Robin Hood Archery
* https://codeforces.com/contest/2014/submission/315528073
*/
#include "../../Src/DataStructure/Mo/Mo.hpp"
#include <iostream>
#include <vector>
int N, Q, A[200020], cnt[1000010];
struct query {
unsigned l, r;
};
using namespace zawa;
void solve() {
std::cin >> N >> Q;
for (int i = 0 ; i < N ; i++) std::cin >> A[i];
std::vector<query> q(Q);
for (int i = 0 ; i < Q ; i++) {
std::cin >> q[i].l >> q[i].r;
q[i].l--;
}
int odd = 0;
auto op = [&](int i) {
cnt[A[i]] ^= 1;
odd += (cnt[A[i]] ? 1 : -1);
};
auto eval = [&](int) -> bool {
return odd == 0;
};
for (bool ans : Mo(q, op, op, op, op, eval, true)) std::cout << (ans ? "YES\n" : "NO\n");
}
int main() {
#ifdef ONLINE_JUDGE
std::cin.tie(nullptr);
std::cout.tie(nullptr);
std::ios::sync_with_stdio(false);
int T;
std::cin >> T;
while (T--) solve();
#else
std::cout << "Hello World\n";
#endif
}
#line 1 "Test/CF/CF974-H.test.cpp"
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/1/ITP1_1_A"
// #define PROBLEM "https://codeforces.com/contest/2014/problem/H"
/*
* Codeforces Round 974 (Div. 3) H. Robin Hood Archery
* https://codeforces.com/contest/2014/submission/315528073
*/
#line 2 "Src/DataStructure/Mo/Mo.hpp"
#line 2 "Src/Template/TypeAlias.hpp"
#include <cstdint>
#include <cstddef>
namespace zawa {
using i16 = std::int16_t;
using i32 = std::int32_t;
using i64 = std::int64_t;
using i128 = __int128_t;
using u8 = std::uint8_t;
using u16 = std::uint16_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;
using usize = std::size_t;
} // namespace zawa
#line 4 "Src/DataStructure/Mo/Mo.hpp"
#include <algorithm>
#include <bit>
#include <cassert>
#include <vector>
#include <type_traits>
namespace zawa {
namespace internal {
// reference: https://codeforces.com/blog/entry/61203?#comment-1064868
u64 hilbertOrder(u64 x, u64 y, usize dim) {
const u64 max{(1ull << dim) - 1};
assert(x <= max);
assert(y <= max);
u64 res{};
for (u64 s{1ull << (dim - 1)} ; s ; s >>= 1) {
bool rx{static_cast<bool>(x & s)}, ry{static_cast<bool>(y & s)};
res = (res << 2) | (rx ? ry ? 2 : 1 : ry ? 3 : 0);
if (!rx) {
if (ry) x ^= max, y ^= max;
std::swap(x, y);
}
}
return res;
}
} // namespace internal
template <class T, class AddL, class AddR, class DelL, class DelR, class Eval>
std::vector<typename std::invoke_result_t<Eval, usize>> Mo(std::vector<T> qs, AddL addL, AddR addR, DelL delL, DelR delR, Eval eval, bool reset = false) {
usize log{};
for (const T& lr : qs) log = std::max<usize>(log, std::bit_width(lr.r));
std::vector<std::pair<T, usize>> ord(qs.size());
std::vector<u64> h(qs.size());
for (usize i{} ; i < qs.size() ; i++) {
ord[i] = {qs[i], i};
h[i] = internal::hilbertOrder(qs[i].l, qs[i].r, log);
}
std::sort(ord.begin(), ord.end(), [&](const auto& L, const auto& R) -> bool {
return h[L.second] < h[R.second];
});
std::vector<typename std::invoke_result_t<Eval, usize>> res(qs.size());
usize L{}, R{};
for (const auto& [lr, id] : ord) {
while (R < lr.r) addR(R++);
while (L > lr.l) addL(--L);
while (R > lr.r) delR(--R);
while (L < lr.l) delL(L++);
res[id] = eval(id);
}
if (reset) while (R > L) delR(--R);
return res;
}
} // namespace zawa
#line 10 "Test/CF/CF974-H.test.cpp"
#include <iostream>
#line 13 "Test/CF/CF974-H.test.cpp"
int N, Q, A[200020], cnt[1000010];
struct query {
unsigned l, r;
};
using namespace zawa;
void solve() {
std::cin >> N >> Q;
for (int i = 0 ; i < N ; i++) std::cin >> A[i];
std::vector<query> q(Q);
for (int i = 0 ; i < Q ; i++) {
std::cin >> q[i].l >> q[i].r;
q[i].l--;
}
int odd = 0;
auto op = [&](int i) {
cnt[A[i]] ^= 1;
odd += (cnt[A[i]] ? 1 : -1);
};
auto eval = [&](int) -> bool {
return odd == 0;
};
for (bool ans : Mo(q, op, op, op, op, eval, true)) std::cout << (ans ? "YES\n" : "NO\n");
}
int main() {
#ifdef ONLINE_JUDGE
std::cin.tie(nullptr);
std::cout.tie(nullptr);
std::ios::sync_with_stdio(false);
int T;
std::cin >> T;
while (T--) solve();
#else
std::cout << "Hello World\n";
#endif
}