#pragma GCC optimize("O3") #pragma GCC target("avx") #include #include #include #include #include using namespace std; int main() { int N, S, X, Y, Z; cin >> N >> S >> X >> Y >> Z; vector A(N); A[0] = S; for (int i = 1; i < N; i++) { (A[i] = (X * A[i - 1] + Y)) %= Z; } const int len = 2e6; bitset bit, mask; for (int i = 0; i < N; i++) { bit[i] = A[i] % 2; } int Q; cin >> Q; while (Q--) { int S, T, U, V; cin >> S >> T >> U >> V; mask.set(); mask >>= (len - (T - S + 1)); mask <<= S - 1; mask &= bit; if (U > S) mask <<= U - S; else mask >>= S - U; bit ^= mask; } string ans; for (int i = 0; i < N; i++) { ans.push_back(char(bit[i] ? 'O' : 'E')); } reverse(ans.begin(), ans.end()); cout << ans << endl; }