#include #include using namespace atcoder; using namespace std; using ll = long long; int main() { int N, Q, P;cin >> N >> Q >> P; vector> dp(N + 1, vector(P, 0)); vector A(N + 1); for (int i = 1;i <= N;i++) cin >> A[i]; dp[1][A[1]] = 1; for (int i = 1;i < N;i++) { int nxt = A[i + 1]; for (int j = 0;j < P;j++) dp[i + 1][(j * nxt) % P] = max(dp[i + 1][(j * nxt) % P], dp[i][j]); for (int j = 0;j < P;j++) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]); dp[i + 1][nxt] = max(dp[i + 1][nxt], i + 1); } while (Q--) { int l, r, k;cin >> l >>r >> k; cout << (dp[r][k] >= l ? "Yes" : "No") << endl; } }