#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define f(i,x,y) for(int i=x;i<y;i++)
#define f2(i,x,y) for(int i=x;i>=y;i--)
#define pii pair<int,int>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
// const int MOD =1000000007;
const int INF = 1e18;
const int N = 2e5;
class SegmentTree
{
public:
int n,x;
vector<int>tree,arr;
SegmentTree(vector<int>&v, int xx){
x=xx;
n = v.size();
arr = v;
tree.assign(4*n,0);
build(1,0,n-1);
}
int query(int l,int r){return query(1,0,n-1,l,r);}
private:
int merge(int a,int b){
return ((a%x)*(b%x))%x;
}
void build(int node,int start,int end){
if(start==end)tree[node] = arr[start];
else {
int mid = (start+end)/2;
build(2*node,start,mid);
build(2*node+1,mid+1,end);
tree[node] = merge(tree[2*node],tree[2*node+1]);
}
}
int query(int node,int start,int end,int l,int r){
if(end<l or start>r)return 1;
if(start==end)return tree[node];
else if(l<=start and end<=r)return tree[node];
else{
int mid = (start+end)/2;
int left = query(2*node,start,mid,l,r);
int right = query(2*node+1,mid+1,end,l,r);
return merge(left,right);
}
}
};
int binpow(int a,int b,int MOD){
a%=MOD;
int res=1;
while(b>0){
if(b&1)res = res*a%MOD;
a=a*a%MOD;
b>>=1;
}
return res;
}
void solve(int tc){
int n,x;
cin >> n >> x;
vector<int>v(n);
for(int i=0;i<n;i++)
cin >> v[i];
int q; cin >> q;
SegmentTree sT(v,x);
while(q--){
int l , r; cin >> l >> r;
l--,r--;
int g = sT.query(l,r);
if(g==0)cout << "Yes" << endl;
else cout << "No" << endl;
}
}
int32_t main(){
Fast
int t=1;
cin >> t;
for(int tc=1;tc<=t;tc++){
solve(tc);
}
return 0;
}