#include "bits/stdc++.h"
using namespace std;
using ll=long long;
void solve();
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cout << setprecision(8) << fixed;
int t=1;
cin>>t;
for(int i=1;i<=t;i++){
// cout<<"Test case# "<<i<<" ";
solve();
}
return 0;
}
void solve(){
ll n,x;cin>>n>>x;
vector<ll>a(n);
for(int i=0;i<n;i++){
cin>>a[i];
a[i]=(a[i]%x)+1;
}
vector<ll>pmul(n+1,1);
for(int i=0;i<n;i++){
pmul[i+1]=(pmul[i]*a[i]);
}
ll q;cin>>q;
while(q--){
ll l,r;cin>>l>>r;
ll reqProd=pmul[r]/pmul[l-1];
if(reqProd%x==1){
cout<<"Yes"<<"\n";
}else{
cout<<"No\n";
}
}
}