import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, S, X, Y, Z = map(int, readline().split()) A = [0] * N A[0] = S & 1 x = S for i in range(1, N): x = (x * X + Y) % Z A[i] = x & 1 A = int(''.join(map(str, reversed(A))), 2) Q = int(readline()) m = map(int, read().split()) for s, t, u, v in zip(m, m, m, m): mask = (1 << t) - 1 B = (A & mask) >> (s - 1) A ^= B << (u - 1) parity = bin(A)[2:][::-1] parity += '0' * (N - len(parity)) answer = parity.replace('0', 'E').replace('1', 'O') print(answer)