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): ai = A[i] for j in range(P): dp[i+1][j] = max(dp[i+1][j], dp[i][j]) jj = j * ai % P dp[i+1][jj] = max(dp[i+1][jj], dp[i][j]) dp[i+1][ai] = i for _ in range(Q): li, ri, k = map(int, input().split()) li -= 1 if dp[ri][k] >= li: print('Yes') else: print('No')