#include <bits/stdc++.h>
using namespace std;
const int MX = 3e5 + 5;
const int N = 1e5 + 5;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
#define f first
#define s second
int SZ, cnt[N], Arr[MX], mx = 0, mn;
pii Ans[MX], tree[4 * N];
piii query[MX];
bool cmp(piii x, piii y){
int _x = x.f.f/SZ, _y = y.f.f/SZ;
if(_x != _y) return _x < _y;
return x.f.s < y.f.s;
}
void build(int node, int st, int en){
if(st == en){
tree[node].f = tree[node].s = 0;
return;
}
int l = 2 * node, r = l + 1, mid = (st + en)/2;
build(l, st, mid);
build(r, mid + 1, en);
tree[node].f = tree[node].s = 0;
}
void update(int node, int st, int en, int id, int val){
if(st >= id && en <= id){
tree[node] = pii(cnt[val], val);
return;
}
if(en < id || st > id) return;
int l = 2 * node, r = l + 1, mid = (st + en)/2;
update(l, st, mid, id, val);
update(r, mid + 1, en, id, val);
if(tree[l].f > tree[r].f) { tree[node].f = tree[l].f; tree[node].s = tree[l].s; }
else { tree[node].f = tree[r].f; tree[node].s = tree[r].s; }
}
void add(int num){
cnt[num]++;
update(1, mn, mx, num, num);
}
void _remove(int num){
cnt[num]--;
update(1, mn, mx, num, num);
}
int main() {
int n, q, c, fir, sec;
scanf("%d %d", &n, &c); mx = 0; mn = N;
SZ = sqrt(n);
for(int i = 0; i < n; scanf("%d", &Arr[i]), mx = max(mx, Arr[i]), mn = min(mn, Arr[i]), i++);
scanf("%d", &q);
for(int i = 0; i < q; i++){
scanf("%d %d", &fir, &sec);
query[i].f.f = --fir;
query[i].f.s = --sec;
query[i].s = i;
}
sort(query, query + q, cmp);
memset(cnt, 0, sizeof(cnt));
build(1, mn, mx);
int left = 0, right = -1;
for(int i = 0; i < q; i++){
int l = query[i].f.f, r = query[i].f.s, id = query[i].s;
while(right < r){
right++;
add(Arr[right]);
}
while(right > r){
_remove(Arr[right]);
right--;
}
while(left < l){
_remove(Arr[left]);
left++;
}
while(left > l){
left--;
add(Arr[left]);
}
int val = (r - l + 1)/2;
pii p = tree[1];
if(p.f <= val) Ans[id] = pii(0,0);
else Ans[id] = pii(1,p.s);
}
for(int i = 0; i < q; i++){
pii p = Ans[i];
if(p.f == 0) printf("no\n");
else printf("yes %d\n", p.s);
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdCBpbnQgTVggPSAzZTUgKyA1Owpjb25zdCBpbnQgTiA9IDFlNSArIDU7CnR5cGVkZWYgcGFpcjxpbnQsaW50PiBwaWk7CnR5cGVkZWYgcGFpcjxwaWksaW50PiBwaWlpOwojZGVmaW5lIGYgZmlyc3QKI2RlZmluZSBzIHNlY29uZAppbnQgU1osIGNudFtOXSwgQXJyW01YXSwgbXggPSAwLCBtbjsKcGlpIEFuc1tNWF0sIHRyZWVbNCAqIE5dOwpwaWlpIHF1ZXJ5W01YXTsKCmJvb2wgY21wKHBpaWkgeCwgcGlpaSB5KXsKCWludCBfeCA9IHguZi5mL1NaLCBfeSA9IHkuZi5mL1NaOwoJaWYoX3ggIT0gX3kpIHJldHVybiBfeCA8IF95OwoJcmV0dXJuIHguZi5zIDwgeS5mLnM7Cn0KCnZvaWQgYnVpbGQoaW50IG5vZGUsIGludCBzdCwgaW50IGVuKXsKCWlmKHN0ID09IGVuKXsKCQl0cmVlW25vZGVdLmYgPSB0cmVlW25vZGVdLnMgPSAwOwoJCXJldHVybjsKCX0KCQoJaW50IGwgPSAyICogbm9kZSwgciA9IGwgKyAxLCBtaWQgPSAoc3QgKyBlbikvMjsKCWJ1aWxkKGwsIHN0LCBtaWQpOwoJYnVpbGQociwgbWlkICsgMSwgZW4pOwoJdHJlZVtub2RlXS5mID0gdHJlZVtub2RlXS5zID0gMDsKfQoKdm9pZCB1cGRhdGUoaW50IG5vZGUsIGludCBzdCwgaW50IGVuLCBpbnQgaWQsIGludCB2YWwpewoJaWYoc3QgPj0gaWQgJiYgZW4gPD0gaWQpewoJCXRyZWVbbm9kZV0gPSBwaW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