/*
* Copyright (c) 2024 Emon Thakur
* All rights reserved.
*/
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define life_is_a_race ios::sync_with_stdio(false); cin.tie(nullptr);
bool notprime[32002];
vector<int>allprime;
void seive()
{
for(int i=2;i<=1000;i++)
{
if(notprime[i]) continue;
for(int j=i+i;j<=32000;j+=i) notprime[j]=true;
}
for(int i=2;i<=32000;i++) {if(!notprime[i]) allprime.push_back(i);}
}
int n,x;
int main()
{
life_is_a_race;
seive();
int t; cin>>t; while(t--)
{
//cout<<"Case "<<tc<<": ";
cin >> n >> x;
vector<int> a(n+1);
for(int i=1;i<=n;i++) cin>>a[i];
map<int,int> mx;
for(auto e:allprime)
{
if(e>x) break;
while(x%e==0)
{
mx[e]++;
x /= e;
}
}
if(x > 1) mx[x]++;
vector<map<int,int>> pfs(n+1);
for(int i=1;i<=n;i++)
{
pfs[i] = pfs[i-1];
for(auto e:mx)
{
while(a[i] % e.first == 0)
{
pfs[i][e.first]++;
a[i] /= e.first;
}
}
}
int q; cin>>q; while(q--)
{
int l,r; cin>>l>>r;
bool ok = true;
for(auto e:mx)
{
if(pfs[r][e.first]-pfs[l-1][e.first] < e.second)
{
ok = false;
break;
}
}
if(ok) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
}
}