#include<bits/stdc++.h>
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define error1(x) cerr<<#x<<" = "<<(x)<<endl
#define error2(a,b) cerr<<"("<<#a<<", "<<#b<<") = ("<<(a)<<", "<<(b)<<")\n";
#define coutall(v) for(auto &it: v) cout << it << " "; cout << endl;
using namespace std;
using ll = long long;
using ld = long double;
const int N = 1e5 + 9;
ll n, x, q;
struct Segment_Tree {
ll t[4 * N];
auto merge(ll l, ll r) { // <== Change this function
return __gcd(l * r, x);
}
void build(int node, int st, int en, vector<ll> &arr) { //=> O(N)
if (st == en) {
t[node] = arr[st];
return;
}
int mid = (st + en) >> 1;
build(node << 1, st, mid, arr); // divide left side
build(node << 1 | 1, mid + 1, en, arr); // divide right side
// Merging left and right portion
auto &Cur = t[node];
auto &Left = t[node << 1];
auto &Right = t[node << 1 | 1];
Cur = merge(Left, Right);
return;
}
ll query(int node, int st, int en, int l, int r) { //=> O(log n)
if (st > r || en < l) { // No overlapping and out of range
return 1; // <== careful
}
if (l <= st && en <= r) { // Complete overlapped (l-r in range)
return t[node];
}
// Partial overlapping
int mid = (st + en) >> 1;
auto Left = query(node << 1, st, mid, l, r);
auto Right = query(node << 1 | 1, mid + 1, en, l, r);
return merge(Left, Right);
}
} st1;
void solve() {
cin >> n >> x;
vector<ll> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i];
v[i] = __gcd(x, v[i]);
}
st1.build(1, 0, n - 1, v);
cin >> q;
int l, r;
while(q--) {
cin >> l >> r; --l, --r;
// cout << st1.query(1, 0, n - 1, l, r) << endl;
if(st1.query(1, 0, n - 1, l, r) % x == 0) yes;
else no;
}
return;
}
signed main() {
ios::sync_with_stdio(false); cin.tie(0);
int tc = 1;
cin >> tc;
for (int t = 1; t <= tc; t++) {
// cout << "Case " << t << ": ";
solve();
}
return 0;
}