#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long Int; typedef vector vint; typedef pair pint; #define mp make_pair template ostream &operator<<(ostream &os, const pair &a) { return os << "(" << a.first << ", " << a.second << ")"; }; template void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; } template void chmin(T &t, const T &f) { if (t > f) t = f; } template void chmax(T &t, const T &f) { if (t < f) t = f; } int in() { int x; scanf("%d", &x); return x; } int N; Int S, X, Y, Z; int Q; char ans[2000010]; uint64_t MASKS[110]; uint64_t a[100010]; uint64_t b[100010]; void generate() { Int s = S; for (int i = 0; i < N; ++i) { if (s & 1) { a[i >> 6] ^= 1ULL << (i & 63); } s = (X * s + Y) % Z; } } int main() { MASKS[0] = 0; for (int d = 1; d <= 64; ++d) { MASKS[d] = MASKS[d - 1] << 1 | 1; } for (; ~scanf("%d%lld%lld%lld%lld", &N, &S, &X, &Y, &Z); ) { #ifdef LOCAL memset(a, 0, sizeof(a)); #endif generate(); for (Q = in(); Q--; ) { /* for (int i = 0; i < N; ++i) { ans[i] = "EO"[(a[i >> 6] >> (i & 63)) & 1]; } ans[N] = '\0'; puts(ans); //*/ const int s = in() - 1; const int t = in(); const int u = in() - 1; const int v = in(); assert(t - s == v - u); const int l = (t - s) >> 6; { const int r = s & 63; const int rr = 64 - r; int p = s >> 6; for (int j = 0; j <= l; ++j) { b[j] = a[p] >> r; b[j] |= a[++p] << rr; } b[l] &= MASKS[(t - s) & 63]; } // cout<<"b : ";pv(b,b+l+1); { const int r = u & 63; const int rr = 64 - r; int p = u >> 6; for (int j = 0; j <= l; ++j) { a[p] ^= b[j] << r; a[++p] ^= b[j] >> rr; } } } for (int i = 0; i < N; ++i) { ans[i] = "EO"[(a[i >> 6] >> (i & 63)) & 1]; } ans[N] = '\0'; puts(ans); } return 0; }