#include <bits/stdc++.h>
#include <ext/numeric>
#include <ext/hash_map>
using namespace std;
using namespace __gnu_cxx;
#define oo 1e9
#define OO 1e18
#define EPS 1e-7
#define f first
#define s second
#define pi acos(-1.0)
#define ll long long
#define ld long double
#define ull unsigned long long
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define popCnt(x) __builtin_popcount(x)
int n,c,m;
int arr[300300];
map<int,vector<int> > idxS;
int cntBit[18][300300];
int getCnt(int v,int l,int r){
return (upper_bound(all(idxS[v]),r)-idxS[v].begin())
-(lower_bound(all(idxS[v]),l)-idxS[v].begin());
}
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "rt", stdin);
//freopen("output.txt", "wt", stdout);
#endif
scanf("%d%d",&n,&c);
for(int i=1;i<=n;i++){
scanf("%d",&arr[i]);
idxS[arr[i]].push_back(i);
}
for(int i=0;i<17;i++)
for(int j=1;j<=n;j++)
cntBit[i][j]=cntBit[i][j-1]+((arr[j]&(1<<i))!=0);
scanf("%d",&m);
while(m--){
int l,r;
scanf("%d%d",&l,&r);
int siz=(r-l+1)/2,cur=0;
for(int i=0;i<17;i++)
if(cntBit[i][r]-cntBit[i][l-1]>siz)cur|=(1<<i);
int cnt=getCnt(cur,l,r);
if(cnt<=siz)printf("no\n");
else printf("yes %d\n",cur);
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNpbmNsdWRlIDxleHQvbnVtZXJpYz4KI2luY2x1ZGUgPGV4dC9oYXNoX21hcD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdXNpbmcgbmFtZXNwYWNlIF9fZ251X2N4eDsKCiNkZWZpbmUgb28JCQkxZTkKI2RlZmluZSBPTwkJCTFlMTgKI2RlZmluZSBFUFMJCQkxZS03CiNkZWZpbmUgZgkJCWZpcnN0CiNkZWZpbmUgcwkJCXNlY29uZAojZGVmaW5lIHBpIAkJCWFjb3MoLTEuMCkKI2RlZmluZSBsbAkJCWxvb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