#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define dbg(a,b,c,d) cerr<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
#define kill(a) {cout<<a<<endl;continue;}
#define KILL(a) {cout<<a<<endl;return 0;}
#define debug cerr<<"Error Found"<<endl;
#define mem(a,b) memset(a,b,sizeof(a))
#define lcm(a, b) (a/__gcd(a,b))*b
#define w(t) cin>>t;while(t--)
#define pi 2 * acos(0.0)
#define endl "\n"
int t, cs = 0;
const int mxn = 1e5 + 3, mod = 1e9 + 7;
int tre[mxn * 4];
int ar[mxn], X;
void build(int st, int ed, int node)
{
if(st == ed)return void(tre[node] = ar[st]);
if(st == ed)return;
int mid = st + ed >> 1;
build(st, mid, node * 2);
build(mid + 1, ed, node * 2 + 1);
tre[node] = 1LL * tre[node * 2] * tre[node * 2 + 1] % X;
}
int query(int st, int ed, int node, int l, int r)
{
if(st > r or ed < l)return 1;
if(st >= l and ed <= r)return tre[node];
int mid = st + ed >> 1;
return 1LL * query(st, mid, node * 2, l, r) * query(mid + 1, ed, node * 2 + 1, l, r) % X;
}
void refresh(int n)
{
for(int i = 1; i <= n * 4; i++)tre[i] = 0;
}
int32_t main()
{
fast;
w(t)
{
int n;
cin >> n >> X;
refresh(n);
for(int j = 1; j <= n; j++)cin >> ar[j];
build(1, n, 1);
int q;
cin >> q;
while(q--)
{
int l, r;
cin >> l >> r;
bool f = (query(1, n, 1, l, r) % X == 0);
cout << (f ? "Yes" : "No") << endl;
}
}
}