#include #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; int main() { int n, q, p; cin >> n >> q >> p; vector a(n); rep(i, n) cin >> a[i]; rep(qi, q) { int l, r, k; cin >> l >> r >> k; --l; vector dp(p); for (int i = l; i < r; ++i) { vector old(p); swap(dp, old); rep(j, p) if (old[j]) { dp[j] = true; dp[(j*a[i])%p] = true; } dp[a[i]] = true; } if (dp[k]) puts("Yes"); else puts("No"); } return 0; }