""" https://yukicoder.me/problems/no/1349 Rを決め撃った時、必要なLの最小値をあらかじめ求めておく """ import sys from sys import stdin N,Q,P = map(int,stdin.readline().split()) A = list(map(int,stdin.readline().split())) dp = [ [0] * P ] for i in range(N): ndp = [x for x in dp[-1]] ndp[A[i]] = i+1 for j in range(P): nidx = j*A[i]%P ndp[nidx] = max(ndp[nidx], dp[-1][j]) dp.append(ndp) ANS = [] for loop in range(Q): L,R,K = map(int,stdin.readline().split()) if dp[R][K] >= L: ANS.append("Yes") else: ANS.append("No") print (*ANS,sep="\n")