/**
* @author: Binoy Barman
* @created: 2024-11-05 21:48:23
**/
#include<bits/stdc++.h>
using namespace std;
#define nl '\n'
#define all(v) v.begin(), v.end()
#define Too_Many_Jobs int tts, tc = 1; cin >> tts; hell: while(tts--)
#define Dark_Lord_Binoy ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifdef LOCAL
#include "debug/whereisit.hpp"
#else
#define dbg(...) 42
#endif
#define int long long
map<int, int> primeFactors(int n) {
map<int, int> pfs;
while(n % 2 == 0) {
pfs[2]++;
n = n / 2;
}
for (int i = 3; i * i <= n; i += 2) {
while (n % i == 0) {
pfs[i]++;
n = n / i;
}
}
if(n > 2) pfs[n]++;
return pfs;
}
int32_t main() {
Dark_Lord_Binoy
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
Too_Many_Jobs {
int n, x;
cin >> n >> x;
auto need = primeFactors(x);
vector<map<int, int>> a(n + 1), ps(n + 1);
for(auto z : need) {
a[0][z.first] = 0;
}
for (int i = 1; i <= n; i++) {
int y;
cin >> y;
for(auto z : need) {
if(y % z.first == 0) {
while(y % z.first == 0) {
a[i][z.first]++;
y /= z.first;
if(y == 0) break;
}
} else {
a[i][z.first] = 0;
}
ps[i][z.first] += a[i][z.first] + ps[i - 1][z.first];
}
}
int q;
cin >> q;
while(q--) {
int l, r;
cin >> l >> r;
map<int, int> cur;
for(auto z : need) {
cur[z.first] = ps[r][z.first] - ps[l - 1][z.first];
}
bool ok = true;
for(auto z : need) {
if(z.second > cur[z.first]) {
ok = false;
break;
}
}
cout << (ok ? "Yes" : "No") << nl;
}
}
return 0;
}