#include #include #include using namespace atcoder; using mint = modint1000000007; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000000000000000 unsigned long long temp[2000]; int main(){ long long N,S,X,Y,Z; cin>>N>>S>>X>>Y>>Z; vector a(N); a[0] = S; rep(i,N-1){ a[i+1] = X * a[i] + Y; a[i+1] %= Z; } int sz = (N+63)/64; vector v(sz,0); rep(i,N){ if(a[i]%2==1){ v[i/64] |= 1ULL<<(i%64); } } v.push_back(0); int Q; cin>>Q; rep(_,Q){ int s,t,u,hoge; scanf("%d %d %d %d",&s,&t,&u,&hoge); s--;t--;u--;hoge--; int len = t-s+1; rep(i,(len+63)/64)temp[i] = 0; rep(i,len/64){ temp[i] = (v[s/64 + i]>>(s%64)) ^ (v[s/64+1 + i]<<(64-s%64)); } rep(i,len%64){ int ind = s + len/64 * 64 + i; if((v[ind/64]>>(ind%64))&1)temp[len/64] |= 1ULL<>(64-u%64); } } rep(i,N){ int b = (v[i/64]>>(i%64))&1; if(b==0)printf("E"); else printf("O"); } cout<