#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 500005;
int n, k, numQuery;
int a[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;
while (numQuery--) {
int left, right;
cin >> left >> right;
stack<int> st;
for (int i = left; i <= right; i++) {
if (st.empty()) {
st.push(a[i]);
} else if (st.top() + a[i] != k) {
st.push(a[i]);
} else {
st.pop();
}
}
cout << (st.empty() ? "YES\n" : "NO\n");
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CgogICAgdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCiAgICBjb25zdCBpbnQgTUFYX04gPSA1MDAwMDU7CgogICAgaW50IG4sIGssIG51bVF1ZXJ5OwogICAgaW50IGFbTUFYX05dOwoKICAgIGludCBtYWluKCkgewogICAgICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oMCk7CiAgICAgICAgY2luLnRpZSgwKTsKICAgICAgICBjb3V0LnRpZSgwKTsKCiAgICAgICAgZnJlb3BlbigiWE1BUy5pbnAiLCAiciIsIHN0ZGluKTsKICAgICAgICBmcmVvcGVuKCJYTUFTLm91dCIsICJ3Iiwgc3Rkb3V0KTsKCiAgICAgICAgY2luID4+IG4gPj4gazsKICAgICAgICBmb3IgKGludCBpID0gMTsgaSA8PSBuOyBpKyspIHsKICAgICAgICAgICAgY2luID4+IGFbaV07CiAgICAgICAgfQogICAgICAgIGNpbiA+PiBudW1RdWVyeTsKCiAgICAgICAgd2hpbGUgKG51bVF1ZXJ5LS0pIHsKICAgICAgICAgICAgaW50IGxlZnQsIHJpZ2h0OwogICAgICAgICAgICBjaW4gPj4gbGVmdCA+PiByaWdodDsKICAgICAgICAgICAgc3RhY2s8aW50PiBzdDsKCiAgICAgICAgICAgIGZvciAoaW50IGkgPSBsZWZ0OyBpIDw9IHJpZ2h0OyBpKyspIHsKICAgICAgICAgICAgICAgIGlmIChzdC5lbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgc3QucHVzaChhW2ldKTsKICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoc3QudG9wKCkgKyBhW2ldICE9IGspIHsKICAgICAgICAgICAgICAgICAgICBzdC5wdXNoKGFbaV0pOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICBzdC5wb3AoKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQoKICAgICAgICAgICAgY291dCA8PCAoc3QuZW1wdHkoKSA/ICJZRVNcbiIgOiAiTk9cbiIpOwogICAgICAgIH0KCiAgICAgICAgcmV0dXJuIDA7CiAgICB9