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