#ifndef LOCAL
#include <bits/stdc++.h>
#define debug(...)
#endif
using namespace std;
#define int long long
#define cinv(v) for (auto &it:v) cin>>it;
#define coutv(v) for (auto &it:v) cout<< it<<' '; cout<<'\n';
int n, q, x;
vector<int> tree;
void update(int node, int start, int end, int idx, int val) {
if (start > idx || end < idx) return;
if (start == end) {
tree[node] = val % x;
return;
}
int mid = (start + end) / 2;
update(node * 2, start, mid, idx, val);
update(node * 2 + 1, mid + 1, end, idx, val);
tree[node] = (tree[node * 2] * tree[node * 2 + 1]) % x;
}
int query(int node, int start, int end, int l, int r) {
if (start > r || end < l) return 1;
if (start >= l && end <= r) return tree[node];
int mid = (start + end) / 2;
int q1 = query(node * 2, start, mid, l, r);
int q2 = query(node * 2 + 1, mid + 1, end, l, r);
return (q1 * q2) % x;
}
void shelby() {
cin >> n >> x;
tree.assign(4 * n + 10, 1);
vector<int> v(n + 1);
for (int i = 1; i <= n; ++i) cin >> v[i], update(1, 1, n, i, v[i]);;
debug(v);
cin >> q;
while (q--) {
int l, r;
cin >> l >> r;
debug(l, r);
if (query(1, 1, n, l, r)) cout << "No\n";
else cout << "Yes\n";
}
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int t = 1;
cin >> t;
for (int _ = 1; _ <= t; ++_) {
// cout << "Case " << _ << ": ";
shelby();
}
}