#include<bits/stdc++.h>
using namespace std;
#define scl(x) scanf("%lld",&x)
#define sc(x) scanf("%d",&x)
#define ll long long
#define lop(i,n) for(int i=0;i<n;++i)
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;
const int mN=3e5+10,mC=1e5+10;
struct node{
node * L, *R;
int sum;
};
int n,c,col[mN];
node * roots[mN];
inline node * build(int s,int e){
node *ret=new node();
if(s==e){
ret->sum=0;
return ret;
}
int m=s+((e-s)>>1);
ret->L =build(s,m);
ret->R =build(m+1,e);
ret->sum=0;
return ret;
}
inline node * add(node *r,int s,int e,int idx){
node *ret=new node;
if(s==e){
ret->sum=r->sum+1;
return ret;
}
int m=s+((e-s)>>1);
if(idx<=m){
ret->L=add(r->L,s,m,idx);
ret->R=r->R;
}
else {
ret->R=add(r->R,m+1,e,idx);
ret->L=r->L;
}
ret->sum=r->sum+1;
return ret;
}
inline int get(node *a,node *b,int s,int e,int mn){
if(s==e){
if(b->sum-a->sum>=mn)return s;
return 0;
}
int m=s+((e-s)>>1);
if(b->L->sum-a->L->sum>=mn)return get(a->L,b->L,s,m,mn);
if(b->R->sum-a->R->sum>=mn)return get(a->R,b->R,m+1,e,mn);
return 0;
}
int main(){
#ifndef ONLINE_JUDGE
freopen("i.txt","r",stdin);
#endif
sc(n),sc(c);
roots[0]=build(1,c);
for(int i=1;i<=n;++i){
sc(col[i]);
roots[i]=add(roots[i-1],1,c,col[i]);
}
int q,a,b,mn;
sc(q);
lop(i,q){
sc(a),sc(b);
mn=((b-a+1)>>1) +1;
int res=get(roots[a-1],roots[b],1,c,mn);
if(res)
printf("yes %d\n",res);
else puts("no");
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCiNkZWZpbmUgc2NsKHgpIHNjYW5mKCIlbGxkIiwmeCkKI2RlZmluZSBzYyh4KSAgc2NhbmYoIiVkIiwmeCkKI2RlZmluZSBsbCBsb25nIGxvbmcKI2RlZmluZSBsb3AoaS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