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