#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define EB emplace_back
#define all(x) std::begin(x), std::end(x)
#define sz(x) (int)(x).size()
#define rep(i, a, b) for(long long i = a; i < (b); ++i)
#define endl '\n'
#define debarr(a, n) cerr << #a << " : ";for(int i = 0; i < n; i++) cerr << a[i] << " "; cerr << endl;
#define debmat(mat, row, col) cerr << #mat << " :\n";for(int i = 0; i < row; i++) {for(int j = 0; j < col; j++) cerr << mat[i][j] << " ";cerr << endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const unordered_set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const unordered_map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
typedef long long lli;
typedef pair<lli, lli> ii; typedef vector<lli> vi;
typedef vector<ii> vii; typedef vector<vi> graph;
template<class T> bool ckmax(T &a, const T& b) {return b > a ? a = b, 1 : 0;}
template<class T> bool ckmin(T &a, const T& b) {return b < a ? a = b, 1 : 0;}
int const MOD = 1000000007;
const int mxN=1e5+10;
vi p(mxN, 1);
vi primes;
void pre() {
p[0]=p[1]=0;
for(int i=2;i<mxN;i++) {
if(p[i]) {
primes.push_back(i);
for(int j=2*i;j<mxN;j+=i) {
p[j]=0;
}
}
}
}
void solve() {
int n,x;
cin>>n>>x;
vi arr(n);
rep(i,0,n) {
cin>>arr[i];
}
map<int,int> mp;
for(auto &prime:primes) {
while(x>1&&x%prime==0) {
mp[prime]++;
x/=prime;
}
if(x==1)break;
}
if(x>1)mp[x]++;
unordered_map<int,int> idx;
int id=0;
for(auto &x:mp) {
idx[x.first]=id++;
}
vector<vector<int>> cnt(n, vector<int>(sz(mp), 0));
rep(i,0,n) {
if(i)cnt[i]=cnt[i-1];
for(auto &x:mp) {
while(arr[i]>1&&arr[i]%x.first==0) {
cnt[i][idx[x.first]]++;
arr[i]/=x.first;
}
if(arr[i]==1)break;
}
}
int q;
cin>>q;
while(q--) {
int l, r;
cin>>l>>r;--l;--r;
bool ok=true;
for(auto &x:mp) {
int tot=cnt[r][idx[x.first]];
if(l==0) {
}else tot-=cnt[l-1][idx[x.first]];
if(tot<x.second) {
ok=false;
break;
}
}
if(ok) {
cout<<"Yes"<<endl;
}else cout<<"No"<<endl;
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
pre();
int t = 1;
cin >> t;
rep(i, 0, t) solve();
}