#include <algorithm>
#include <bitset>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, S, X, Y, Z;
    cin >> N >> S >> X >> Y >> Z;

    vector<long long> A(N);
    A[0] = S;
    for (int i = 1; i < N; i++) {
        (A[i] = (X * A[i - 1] + Y)) %= Z;
    }

    const int len = 1e5;
    bitset<len> bit[25], all;
    all.set();

    for (int i = 0; i < N; i++) {
        bit[i / len][i % len] = A[i] % 2;
    }

    int Q;
    cin >> Q;

    while (Q--) {
        int S, T, U, V;
        cin >> S >> T >> U >> V;
        S--;
        U--;

        bitset<len> tmp;

        int P = (S / len + 1) * len;
        if (P <= T) {
            tmp |= bit[S / len] >> (S % len);
            tmp |= (bit[P / len] & (all >> (len - (T - P)))) << (P - S);
        } else {
            tmp |= (bit[S / len] >> (S % len)) & (all >> (len - (T - S)));
        }

        int Q = (U / len + 1) * len;
        bit[U / len] ^= tmp << (U % len);
        bit[Q / len] ^= tmp >> (Q - U);
    }

    string ans;
    for (int i = 0; i < N; i++) {
        ans.push_back(char(bit[i / len][i % len] ? 'O' : 'E'));
    }

    cout << ans << endl;
}