#include using namespace std; #define REP(i,a,b) for(i=a;istB){if(B==R){if(Z)b[B-G-1]^=(a[B]&p[Y]&q[E])<<(64-Z);b[B-G]^=(a[B]&p[Y]&q[E])>>Z;}else{if(Z)b[B-G-1]^=(a[B]&q[E])<<(64-Z);b[B-G]^=(a[B]&q[E])>>Z;REP(i,B+1,R){if(Z)b[i-G-1]^=a[i]<<(64-Z);b[i-G]^=a[i]>>Z;}if(Z)b[R-G-1]^=(a[R]&p[Y])<<(64-Z);b[R-G]^=(a[R]&p[Y])>>Z;}}else{if(B==R){b[B-G]^=(a[B]&p[Y]&q[E])>>Z;if(Z)b[B-G-1]^=(a[B]&p[Y]&q[E])<<(64-Z);}else{b[R-G]^=(a[R]&p[Y])>>Z;if(Z)b[R-G-1]^=(a[R]&p[Y])<<(64-Z);for(i=R-1;i>B;i--){b[i-G]^=a[i]>>Z;if(Z)b[i-G-1]^=a[i]<<(64-Z);}b[B-G]^=(a[B]&q[E])>>Z;if(Z)b[B-G-1]^=(a[B]&q[E])<<(64-Z);}}} void bitOR(ull a[], ull b[], int stA, int stB, int len){int i,B,E,R,Y,X,G,Z;static ull p[65],q[65];static int f=0;if(!f){f=1;p[0]=0;rep(i,64)p[i+1]=(p[i]<<1)|1ULL;rep(i,65)q[i]=p[64]^p[i];}B=stA/64;E=stA%64;R=(stA+len)/64;Y=(stA+len)%64;X=stA-stB;G=X/64;Z=X%64;if(Z<0)Z+=64,G--;if(stA>stB){if(B==R){if(Z)b[B-G-1]|=(a[B]&p[Y]&q[E])<<(64-Z);b[B-G]|=(a[B]&p[Y]&q[E])>>Z;}else{if(Z)b[B-G-1]|=(a[B]&q[E])<<(64-Z);b[B-G]|=(a[B]&q[E])>>Z;REP(i,B+1,R){if(Z)b[i-G-1]|=a[i]<<(64-Z);b[i-G]|=a[i]>>Z;}if(Z)b[R-G-1]|=(a[R]&p[Y])<<(64-Z);b[R-G]|=(a[R]&p[Y])>>Z;}}else{if(B==R){b[B-G]|=(a[B]&p[Y]&q[E])>>Z;if(Z)b[B-G-1]|=(a[B]&p[Y]&q[E])<<(64-Z);}else{b[R-G]|=(a[R]&p[Y])>>Z;if(Z)b[R-G-1]|=(a[R]&p[Y])<<(64-Z);for(i=R-1;i>B;i--){b[i-G]|=a[i]>>Z;if(Z)b[i-G-1]|=a[i]<<(64-Z);}b[B-G]|=(a[B]&q[E])>>Z;if(Z)b[B-G-1]|=(a[B]&q[E])<<(64-Z);}}} ll A[2000010], B[2000010]; int arr[2000001]; ull bit[100000]; int N, X, Y, Z, Q; int S, T, U, V, L; char mode[10]; char res[2000100]; int main(){ int i, j, k; scanf("%d%d%d%d%d",&N,&S,&X,&Y,&Z); A[0] = S; REP(i,1,N) A[i] = (A[i-1] * X + Y) % Z; rep(i,N) if(A[i]%2) bit[i/64] |= (1ULL << (i%64)); scanf("%d",&Q); while(Q--){ scanf("%d%d%d%d",&S,&T,&U,&V); S--; U--; L = T-S; bitXOR(bit, bit, S, U, L); } res[N] = '\0'; rep(i,N){ if(bit[i/64]&(1ULL<<(i%64))){ res[i] = 'O'; } else { res[i] = 'E'; } } puts(res); return 0; }