#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define endl '\n'
#define debug cout<<"HERE"<<endl;
#define ff first
#define ss second
void edm()
{
ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
}
const int N = 1e5+5;
int cnt[N][12];
void solve()
{
int n,k;cin>>n>>k;
int arr[n+1];
for(int i=1;i<=n;i++)cin>>arr[i];
map<int,int>mp;
int kk = k;
vector<int>v;
for(int i=2;i*i<=k;i++)
{
while(kk%i==0)
{
mp[i]++;
kk = kk/i;
}
}
if(kk!=1)mp[kk]++;
for(auto i:mp)
{
v.pb(i.ff);
}
int koyta = mp.size();
for(int i=1;i<=n;i++)
{
for(int j=0;j<v.size();j++)
{
while(arr[i]%v[j]==0)
{
cnt[i][j]++;
arr[i] = arr[i]/v[j];
}
}
}
for(int j=0;j<koyta;j++)
{
for(int i=1;i<=n;i++)
{
cnt[i][j] = cnt[i-1][j] + cnt[i][j];
}
}
int q;cin>>q;
while(q--)
{
int a,b;cin>>a>>b;
int chk=1;
for(int i=0;i<v.size();i++)
{
int koto = cnt[b][i] - cnt[a-1][i];
auto it = mp.find(v[i]);
if(it!=mp.end())
{
if(koto<mp[v[i]])
{
chk=0;
break;
}
}
}
if(chk)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
}
int32_t main()
{
edm();
int t = 1;
cin >> t;
for(int i=1;i<=t;i++)
{
solve();
}
}