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