#define _GLIBCXX_FILESYSTEM
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5+2;
ll a[N];
struct ST{
#define lc (n<<1)
#define rc (n<<1)|1
ll t[4*N],x;
ST(ll _x){
memset(t,0,sizeof(t));
x = _x;
}
inline ll combine(ll a,ll b){
return a * b % x;
}
inline void build(ll n,ll b,ll e){
if(b==e){
t[n]=a[b];
return;
}
ll mid=(b+e)>>1;
build(lc,b,mid);
build(rc,mid+1,e);
t[n]=combine(t[lc],t[rc]);
}
inline ll get(ll n,ll b,ll e,ll qb,ll qe){
if(e<qb || b>qe) return 1;
if(b>=qb && e<=qe){
return t[n];
}
ll mid=(b+e)>>1;
return combine(get(lc,b,mid,qb,qe),get(rc,mid+1,e,qb,qe));
}
};
void solve() {
ll n,x;
cin >> n >> x;
for(int i = 1; i <= n; i++)
cin >> a[i];
ST st(x);
st.build(1,1,n);
int q;
cin >> q;
while(q--) {
int l,r;
cin >> l >> r;
if(st.get(1,1,n,l,r) == 0) cout << "Yes\n";
else cout << "No\n";
}
return;
}
int32_t main() {
ios_base::sync_with_stdio(false);cin.tie(NULL);
int tc = 1;
cin >> tc;
for(int kase = 1; kase <= tc; kase++) {
//cout << "Case " << kase << ": ";
solve();
}
return 0;
}