#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
#define MP make_pair
#define PB push_back
#define FF first
#define SS second
#define FORN(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define MOD 1000000007
#define INF 2000000000
int candF[4], candS[4];
vector<PII> data; vector< vector<int> > common; int csz;
const int MAXN = 200010;
int f[MAXN];
int N, M, Q;
int main() {
scanf("%d%d", &N, &M);
for (int i = 1; i <= N; i++) {
scanf("%d", &f[i]); data.PB(MP(f[i], i));
}
data.PB(MP(N+1,N+1));
sort(data.begin(), data.end());
int diffidx = -1;
for (int i = 0; i < data.size(); i++) {
if (i > 0 && data[i].FF != data[i-1].FF) {
int cnt = i-1 - diffidx;
if (cnt >= 500) {
common.PB(vector<int>());
for (int j = diffidx + 1; j < i; j++) common[csz].PB(data[j].SS);
csz++;
}
diffidx = i-1;
}
}
scanf("%d", &Q); int l, r;
for (int i = 0; i < Q; i++) {
scanf("%d%d", &l, &r); int qlen = r - l + 1;
if (qlen >= 1500) {
int good = 0; bool found = false;
for (int j = 0; j < csz; j++) {
int cnt = upper_bound(common[j].begin(), common[j].end(), r) - lower_bound(common[j].begin(), common[j].end(), l);
good += (3 * cnt >= 2 * qlen) + (3 * cnt >= qlen);
if (good >= 2) { found = true; break; }
}
if (found) printf("YES\n");
else printf("NO\n");
}
else {
int candsz = 0; vector<PII> cand;
for (int j = l; j <= r; j++) {
bool inserted = false;
for (int k = 0; k < cand.size(); k++) {
if (cand[k].SS == f[j]) {
cand[k].FF += 1;
inserted = true;
}
}
if (!inserted) cand.PB(MP(1, f[j]));
sort(cand.rbegin(), cand.rend());
if (cand.size() == 4) {
for (int k = 0; k < cand.size(); k++) cand[k].FF -= 1;
while (cand[cand.size()-1].FF == 0) cand.pop_back();
}
}
vector<int> candcnt(cand.size());
for (int j = l; j <= r; j++) {
for (int k = 0; k < cand.size(); k++) {
if (f[j] == cand[k].SS) candcnt[k]++;
}
}
int good = 0;
for (int k = 0; k < cand.size(); k++) {
good += (3 * candcnt[k] >= 2 * qlen) + (3 * candcnt[k] >= qlen);
}
if (good >= 2) printf("YES\n");
else printf("NO\n");
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8aW9tYW5pcD4KI2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzZXQ+CiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlIDxtYXA+CiNpbmNsdWRlIDxjbWF0aD4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPG1lbW9yeS5oPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8c3N0cmVhbT4KI2luY2x1ZGUgPGNzdGRsaWI+CiNpbmNsdWRlIDxjdGltZT4KI2luY2x1ZGUgPGNhc3NlcnQ+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdHlwZWRlZiBsb25nIGxvbmcgTEw7CnR5cGVkZWYgcGFpcjxpbnQsaW50PiBQSUk7CgojZGVmaW5lIE1QIG1ha2VfcGFpcgojZGVmaW5lIFBCIHB1c2hfYmFjawojZGVmaW5lIEZGIGZpcnN0CiNkZWZpbmUgU1Mgc2Vjb25kCgojZGVmaW5lIEZPUk4oaSwgbikgZm9yIChpbnQgaSA9IDA7IGkgPCAgKGludCkobik7IGkrKykKI2RlZmluZSBGT1IxKGksIG4pIGZvciAoaW50IGkgPSAxOyBpIDw9IChpbnQpKG4pOyBpKyspCiNkZWZpbmUgRk9SRChpLCBuKSBmb3IgKGludCBpID0gKGludCkobikgLSAxOyBpID49IDA7IGktLSkKCiNkZWZpbmUgTU9EIDEwMDAwMDAwMDcKI2RlZmluZSBJTkYgMjAwMDAwMDAwMAoKaW50IGNhbmRGWzRdLCBjYW5kU1s0XTsKCnZlY3RvcjxQSUk+IGRhdGE7IHZlY3RvcjwgdmVjdG9yPGludD4gPiBjb21tb247IGludCBjc3o7Cgpjb25zdCBpbnQgTUFYTiA9IDIwMDAxMDsKaW50IGZbTUFYTl07CgppbnQgTiwgTSwgUTsKCmludCBtYWluKCkgewogICAgc2NhbmYoIiVkJWQiLCAmTiwgJk0pOwoKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IE47IGkrKykgewogICAgICAgIHNjYW5mKCIlZCIsICZmW2ldKTsgZGF0YS5QQihNUChmW2ldLCBpKSk7CiAgICB9CgogICAgZGF0YS5QQihNUChOKzEsTisxKSk7CgogICAgc29ydChkYXRhLmJlZ2luKCksIGRhdGEuZW5kKCkpOwoKICAgIGludCBkaWZmaWR4ID0gLTE7CgogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBkYXRhLnNpemUoKTsgaSsrKSB7CiAgICAgICAgaWYgKGkgPiAwICYmIGRhdGFbaV0uRkYgIT0gZGF0YVtpLTFdLkZGKSB7CiAgICAgICAgICAgIGludCBjbnQgPSBpLTEgLSBkaWZmaWR4OwoKICAgICAgICAgICAgaWYgKGNudCA+PSA1MDApIHsKICAgICAgICAgICAgICAgIGNvbW1vbi5QQih2ZWN0b3I8aW50PigpKTsKICAgICAgICAgICAgICAgIGZvciAoaW50IGogPSBkaWZmaWR4ICsgMTsgaiA8IGk7IGorKykgY29tbW9uW2Nzel0uUEIoZGF0YVtqXS5TUyk7CiAgICAgICAgICAgICAgICBjc3orKzsKICAgICAgICAgICAgfQoKICAgICAgICAgICAgZGlmZmlkeCA9IGktMTsKICAgICAgICB9CiAgICB9CgogICAgc2NhbmYoIiVkIiwgJlEpOyBpbnQgbCwgcjsKCiAgICBmb3IgKGludCBpID0gMDsgaSA8IFE7IGkrKykgewogICAgICAgIHNjYW5mKCIlZCVkIiwgJmwsICZyKTsgaW50IHFsZW4gPSByIC0gbCArIDE7CgogICAgICAgIGlmIChxbGVuID49IDE1MDApIHsKICAgICAgICAgICAgaW50IGdvb2QgPSAwOyBib29sIGZvdW5kID0gZmFsc2U7CgogICAgICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IGNzejsgaisrKSB7CiAgICAgICAgICAgICAgICBpbnQgY250ID0gdXBwZXJfYm91bmQoY29tbW9uW2pdLmJlZ2luKCksIGNvbW1vbltqXS5lbmQoKSwgcikgLSBsb3dlcl9ib3VuZChjb21tb25bal0uYmVnaW4oKSwgY29tbW9uW2pdLmVuZCgpLCBsKTsKCiAgICAgICAgICAgICAgICBnb29kICs9ICgzICogY250ID49IDIgKiBxbGVuKSArICgzICogY250ID49IHFsZW4pOwogICAgICAgICAgICAgICAgaWYgKGdvb2QgPj0gMikgeyBmb3VuZCA9IHRydWU7IGJyZWFrOyB9CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIGlmIChmb3VuZCkgcHJpbnRmKCJZRVNcbiIpOwogICAgICAgICAgICBlbHNlIHByaW50ZigiTk9cbiIpOwogICAgICAgIH0KICAgICAgICBlbHNlIHsKICAgICAgICAgICAgaW50IGNhbmRzeiA9IDA7IHZlY3RvcjxQSUk+IGNhbmQ7CgogICAgICAgICAgICBmb3IgKGludCBqID0gbDsgaiA8PSByOyBqKyspIHsKICAgICAgICAgICAgICAgIGJvb2wgaW5zZXJ0ZWQgPSBmYWxzZTsKCiAgICAgICAgICAgICAgICBmb3IgKGludCBrID0gMDsgayA8IGNhbmQuc2l6ZSgpOyBrKyspIHsKICAgICAgICAgICAgICAgICAgICBpZiAoY2FuZFtrXS5TUyA9PSBmW2pdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhbmRba10uRkYgKz0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgaW5zZXJ0ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICBpZiAoIWluc2VydGVkKSBjYW5kLlBCKE1QKDEsIGZbal0pKTsKCiAgICAgICAgICAgICAgICBzb3J0KGNhbmQucmJlZ2luKCksIGNhbmQucmVuZCgpKTsKCiAgICAgICAgICAgICAgICBpZiAoY2FuZC5zaXplKCkgPT0gNCkgewogICAgICAgICAgICAgICAgICAgIGZvciAoaW50IGsgPSAwOyBrIDwgY2FuZC5zaXplKCk7IGsrKykgY2FuZFtrXS5GRiAtPSAxOwogICAgICAgICAgICAgICAgICAgIHdoaWxlIChjYW5kW2NhbmQuc2l6ZSgpLTFdLkZGID09IDApIGNhbmQucG9wX2JhY2soKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQoKICAgICAgICAgICAgdmVjdG9yPGludD4gY2FuZGNudChjYW5kLnNpemUoKSk7CgogICAgICAgICAgICBmb3IgKGludCBqID0gbDsgaiA8PSByOyBqKyspIHsKICAgICAgICAgICAgICAgIGZvciAoaW50IGsgPSAwOyBrIDwgY2FuZC5zaXplKCk7IGsrKykgewogICAgICAgICAgICAgICAgICAgIGlmIChmW2pdID09IGNhbmRba10uU1MpIGNhbmRjbnRba10rKzsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQoKICAgICAgICAgICAgaW50IGdvb2QgPSAwOwoKICAgICAgICAgICAgZm9yIChpbnQgayA9IDA7IGsgPCBjYW5kLnNpemUoKTsgaysrKSB7CiAgICAgICAgICAgICAgICBnb29kICs9ICgzICogY2FuZGNudFtrXSA+PSAyICogcWxlbikgKyAoMyAqIGNhbmRjbnRba10gPj0gcWxlbik7CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIGlmIChnb29kID49IDIpIHByaW50ZigiWUVTXG4iKTsKICAgICAgICAgICAgZWxzZSBwcmludGYoIk5PXG4iKTsKICAgICAgICB9CiAgICB9CiAgICAKICAgIHJldHVybiAwOwp9Cg==