#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
void solve()
{
ll n,x,val,q,l,r;
cin>>n>>x;
val=x;
vector <ll> v(n+1);
for(int i=1;i<=n;i++) cin>>v[i];
map <ll,ll> mp;
for(int i=2;i*i<=x;i++){
if(x%i==0){
while(x%i==0){
mp[i]++;
x/=i;
}
}
}
if(x>1) mp[x]++;
vector <map<ll,ll>> vmp(n+1);
for(auto it:mp){
for(int i=1;i<=n;i++){
ll cnt=0;
while(v[i]%it.first==0){
cnt++;
v[i]/=it.first;
}
vmp[i][it.first]=vmp[i-1][it.first]+cnt;
}
}
cin>>q;
while(q--){
cin>>l>>r;
ll possible=0;
for(auto it:mp){
ll have=(vmp[r][it.first]-vmp[l-1][it.first]);
if(have<it.second){
possible=1;
break;
}
}
if(possible){
cout<<"No\n";
}
else cout<<"Yes\n";
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t=1;cin>>t;
while(t--){
solve();
}
}