#include<bits/stdc++.h>
using namespace std;
/*
#ifndef ONLINE_JUDGE
#include "DEBUG.h"
#define bug(...) __f (#__VA_ARGS__, __VA_ARGS__)
#endif*/
#define first_in_out ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define double long double
#define min_heap priority_queue <ll, vector<ll>, greater<ll>>
#define print(a) for(auto x : a) cout << x << " ";
#define printpair(a) for(auto x : a) cout << x.first << " " << x.second<<"\n";
const ll N = 1e6 + 1;
ll arr[N];
int x;
template<class T>
struct segtree
{
T tree[4 * N];
void init(ll node, ll s, ll e)
{
if (s == e)
{
tree[node] = arr[s] % x;
return;
}
ll mid = (s + e) / 2;
ll left = node * 2;
ll right = left + 1;
init(left, s, mid);
init(right, mid + 1, e);
tree[node] = (tree[left] * tree[right]) % x;
}
T query(ll node, ll s, ll e, ll l, ll r)
{
if (s > r or e < l)
return -1;
if (s >= l and e <= r)
return tree[node];
ll mid = (s + e) / 2;
ll left = node * 2;
ll right = left + 1;
auto p1 = query(left, s, mid, l, r);
auto p2 = query(right, mid + 1, e, l, r);
return ((p1 % x) * (p2 % x)) % x;
}
void update(ll node, ll s, ll e, ll pos, ll val)
{
if (pos > e or pos < s)
return ;
if (s == e and s == pos) {
tree[node] = val;
return;
}
ll mid = (s + e) / 2;
ll left = node * 2;
ll right = left + 1;
update(left, s, mid, pos, val);
update(right, mid + 1, e, pos, val);
tree[node] = (tree[left] * tree[right]) % x;
}
};
void solve()
{
ll n, q;
cin >> n >> x;
for (ll i = 0; i < n; i++)
cin >> arr[i];
segtree<ll>seg;
seg.init(1, 0, n - 1);
cin >> q;
while (q--)
{
int l, r;
cin >> l >> r;
l--, r--;
if (seg.query(1, 0, n - 1, l, r) == 0)
cout << "Yes" << "\n";
else
cout << "No\n";
}
}
int main()
{
first_in_out
//clock_t z = clock();
int t = 1;
cin >> t;
while (t--)
solve();
//cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);
}