#define _CRT_SECURE_NO_WARNINGS #include "bits/stdc++.h" using namespace std; unsigned long long A[210000]; unsigned long long C[21000]; #define div 60 int main() { int N, S, X, Y, Z; scanf("%d %d %d %d %d", &N, &S, &X, &Y, &Z); int pre = S; for (int i = 0; i < N; i++) { int abase = i / div; int apos = i % div; if (pre % 2) A[abase] |= 1ULL << apos; pre = (int)(((long long)X * pre + Y) % Z); } int Q; scanf("%d", &Q); for (int l = 0; l < Q; l++) { int sk, tk, uk, vk; scanf("%d %d %d %d", &sk, &tk, &uk, &vk); sk--; tk--; uk--; vk--; int sb, sp, tb, tp, ub, up, vb, vp; sb = sk / div; sp = sk % div; tb = tk / div; tp = tk % div; ub = uk / div; up = uk % div; vb = vk / div; vp = vk % div; int cp = up; int cb = 0; C[cb] = 0; for (int i = sb; i <= tb; i++) { int target = div; if (i == tb) target = tp; while (sp <= target){ int len = min(target - sp + 1, div - cp + 1); C[cb] |= (((1ULL << len) - 1ULL) & (A[i] >> sp)) << cp; sp += len; cp += len; if (cp > div){ cb++; C[cb] = 0; cp = 0; } } sp = 0; } for (int i = ub; i <= vb; i++) { A[i] ^= C[i - ub]; } } for (int i = 0; i < N; i++) { int b = i / div; int p = i % div; if ((A[b] >> p) & 1ULL) printf("O"); else printf("E"); } printf("\n"); }