import sys import math import bisect from heapq import heapify, heappop, heappush from collections import deque, defaultdict, Counter from functools import lru_cache from itertools import accumulate, combinations, permutations, product sys.setrecursionlimit(1000000) MOD = 10 ** 9 + 7 MOD99 = 998244353 input = lambda: sys.stdin.readline().strip() NI = lambda: int(input()) NMI = lambda: map(int, input().split()) NLI = lambda: list(NMI()) SI = lambda: input() SMI = lambda: input().split() SLI = lambda: list(SMI()) EI = lambda m: [NLI() for _ in range(m)] def main(): N, S, X, Y, Z = NMI() Q = NI() STUV = EI(Q) A = [0] * N A[0] = S for i in range(N-1): A[i+1] = (A[i] * X + Y) % Z P = 0 b = 1 for i, a in enumerate(A): if a % 2: P |= b b <<= 1 for s, t, u, v in STUV: s -= 1 u -= 1 b = (P >> s) & ((1<<(t-s))-1) P ^= b << u ans = [] for _ in range(N): b = P & 1 if b: ans.append("O") else: ans.append("E") P >>= 1 print("".join(ans)) if __name__ == "__main__": main()