import sys input = sys.stdin.buffer.readline N, Q, P = map(int, input().split()) A = list(map(int, input().split())) dp = [[-1] * P for _ in range(N + 1)] for i in range(N): for j in range(P): dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]) dp[i + 1][(j * A[i]) % P] = max(dp[i + 1][(j * A[i]) % P], dp[i][j]) dp[i + 1][A[i]] = i for _ in range(Q): l, r, k = map(int, input().split()) l -= 1 if dp[r][k] >= l: print("Yes") else: print("No")