#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';
const int N = 1e5 + 5, K = 20;
int n, q, x, arr[N], st[K + 1][N];
void build() {
copy(arr, arr + n + 1, st[0]);
int k = __lg(n);
for (int i = 1; i <= k; ++i) for (int j = 0; j + (1 << i) <= N; ++j) st[i][j] = (st[i - 1][j] * st[i - 1][j + (1 << (i - 1))]) % x;
}
int query(int L, int R) {
int ret = 1;
for (int i = K; i >= 0; --i) {
if ((1 << i) <= R - L + 1) {
ret = (ret * st[i][L]) % x;
L += 1 << i;
}
}
return ret;
}
void shelby() {
cin >> n >> x;
for (int i = 1; i <= n; ++i) cin >> arr[i];
build();
cin >> q;
while (q--) {
int l, r;
cin >> l >> r;
debug(l, r);
if (query(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();
}
}