#include //using namespace std; #pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++) #define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++) #define per(i,j,n) for(int i=(int)(j);(int)(n)<=i;i--) #define ALL(a) (a).begin(),(a).end() #define pb emplace_back #define mp std::make_pair // #define endl "\n" //using std::endl; using std::cin; using std::cout; using ll=int; using std::vector; using std::string; using std::upper_bound; using std::lower_bound; using vi=vector; using vii=vector; using pii=std::pair; int N,Q,P; vii dp; vii mem; vi A; ll dfs(ll now,ll val){ if(dp[now][val]!=-1) return dp[now][val]; if(now==0) return 0; if(A[now-1]==val) return now; dp[now][val]=std::max(dp[now][val],dfs(now-1,val)); if(mem[A[now-1]][val]!=-1) dp[now][val]=std::max(dp[now][val],dfs(now-1,mem[A[now-1]][val])); return dp[now][val]; } int main(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); std::random_device rnd; std::mt19937 mt(rnd()); cin>>N>>Q>>P; A.resize(N); rep(i,0,N) cin>>A[i]; dp.resize(N+1,vi(P,-1)); mem.resize(P,vi(P,-1)); vi cnt(P); rep(i,0,P){ rep(j,0,P) mem[i][i*j%P]=j; } while(Q--){ ll L,R,K; cin>>L>>R>>K; string ans="No"; if(dfs(R,K)>=L) ans="Yes"; cout<