import sys readline = sys.stdin.readline N, Q, P = map(int, readline().split()) A = list(map(int, readline().split())) dp = [[-1]*(P+2) for _ in range(N+1)] dp[0][P+1] = 0 for i in range(N): a = A[i] for p in range(P+2): dp[i+1][p] = max(dp[i+1][p], dp[i][p]) dp[i+1][p*a%P] = max(dp[i+1][p*a%P], dp[i][p]) dp[i+1][a] = i+1 Ans = [None]*Q for qu in range(Q): l, r, x = map(int, readline().split()) if dp[r][x] >= l: Ans[qu] = 'Yes' else: Ans[qu] = 'No' print('\n'.join(Ans))