#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 500005;
int n, k, a[MAX_N], p[MAX_N], ip[MAX_N];
int numQuery, l[MAX_N], r[MAX_N];
bool ans[MAX_N];
vector<int> ids[MAX_N];
map<int, int> mark[MAX_N];
map<int, bool> reach[MAX_N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
freopen("XMAS.inp", "r", stdin);
freopen("XMAS.out", "w", stdout);
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
cin >> numQuery;
for (int i = 1; i <= numQuery; i++) {
cin >> l[i] >> r[i];
ids[r[i]].push_back(i);
}
a[0] = -1;
reach[0][0] = true;
for (int i = 1; i <= n; i++) {
p[i] = mark[i - 1][k - a[i]];
ip[p[i]] = i;
if (p[i]) {
swap(mark[i], mark[p[i] - 1]);
swap(reach[i], reach[p[i] - 1]);
}
mark[i][a[i]] = i;
reach[i][i] = true;
for (int id : ids[i]) {
ans[id] = reach[r[id]][l[id] - 1];
}
}
for (int i = 1; i <= numQuery; i++) {
cout << (ans[i] ? "YES\n" : "NO\n");
}
return 0;
}
ICAgI2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CgogICAgdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCiAgICBjb25zdCBpbnQgTUFYX04gPSA1MDAwMDU7CgogICAgaW50IG4sIGssIGFbTUFYX05dLCBwW01BWF9OXSwgaXBbTUFYX05dOwogICAgaW50IG51bVF1ZXJ5LCBsW01BWF9OXSwgcltNQVhfTl07CiAgICBib29sIGFuc1tNQVhfTl07CiAgICB2ZWN0b3I8aW50PiBpZHNbTUFYX05dOwogICAgbWFwPGludCwgaW50PiBtYXJrW01BWF9OXTsKICAgIG1hcDxpbnQsIGJvb2w+IHJlYWNoW01BWF9OXTsKCiAgICBpbnQgbWFpbigpIHsKICAgICAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApOwogICAgICAgIGNpbi50aWUoMCk7CiAgICAgICAgY291dC50aWUoMCk7CgogICAgICAgIGZyZW9wZW4oIlhNQVMuaW5wIiwgInIiLCBzdGRpbik7CiAgICAgICAgZnJlb3BlbigiWE1BUy5vdXQiLCAidyIsIHN0ZG91dCk7CgogICAgICAgIGNpbiA+PiBuID4+IGs7CiAgICAgICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKSB7CiAgICAgICAgICAgIGNpbiA+PiBhW2ldOwogICAgICAgIH0KICAgICAgICBjaW4gPj4gbnVtUXVlcnk7CiAgICAgICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbnVtUXVlcnk7IGkrKykgewogICAgICAgICAgICBjaW4gPj4gbFtpXSA+PiByW2ldOwogICAgICAgICAgICBpZHNbcltpXV0ucHVzaF9iYWNrKGkpOwogICAgICAgIH0KCiAgICAgICAgYVswXSA9IC0xOwogICAgICAgIHJlYWNoWzBdWzBdID0gdHJ1ZTsKICAgICAgICBmb3IgKGludCBpID0gMTsgaSA8PSBuOyBpKyspIHsKICAgICAgICAgICAgcFtpXSA9IG1hcmtbaSAtIDFdW2sgLSBhW2ldXTsKICAgICAgICAgICAgaXBbcFtpXV0gPSBpOwogICAgICAgICAgICBpZiAocFtpXSkgewogICAgICAgICAgICAgICAgc3dhcChtYXJrW2ldLCBtYXJrW3BbaV0gLSAxXSk7CiAgICAgICAgICAgICAgICBzd2FwKHJlYWNoW2ldLCByZWFjaFtwW2ldIC0gMV0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG1hcmtbaV1bYVtpXV0gPSBpOwogICAgICAgICAgICByZWFjaFtpXVtpXSA9IHRydWU7CiAgICAgICAgICAgIGZvciAoaW50IGlkIDogaWRzW2ldKSB7CiAgICAgICAgICAgICAgICBhbnNbaWRdID0gcmVhY2hbcltpZF1dW2xbaWRdIC0gMV07CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG51bVF1ZXJ5OyBpKyspIHsKICAgICAgICAgICAgY291dCA8PCAoYW5zW2ldID8gIllFU1xuIiA6ICJOT1xuIik7CiAgICAgICAgfQoKICAgICAgICByZXR1cm4gMDsKICAgIH0=