def main(): import sys input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]); ptr += 1 S = int(input[ptr]); ptr += 1 X = int(input[ptr]); ptr += 1 Y = int(input[ptr]); ptr += 1 Z = int(input[ptr]); ptr += 1 # Generate initial array A with parity (0 for even, 1 for odd) A = [0] * N current = S A[0] = current % 2 for i in range(1, N): current = (X * current + Y) % Z A[i] = current % 2 Q = int(input[ptr]); ptr += 1 for _ in range(Q): S_op = int(input[ptr]); ptr += 1 T_op = int(input[ptr]); ptr += 1 U_op = int(input[ptr]); ptr += 1 V_op = int(input[ptr]); ptr += 1 # Adjust for 0-based indices S_0 = S_op - 1 T_0 = T_op - 1 U_0 = U_op - 1 V_0 = V_op - 1 # Extract B as a list of parities B = A[S_0 : T_0 + 1] # Apply XOR to A[U..V] for i in range(U_0, V_0 + 1): A[i] ^= B[i - U_0] # Convert to the required output string output = [] for num in A: if num == 0: output.append('E') else: output.append('O') print(''.join(output)) if __name__ == "__main__": main()