import sys def main(): 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 Q = int(input[ptr]); ptr +=1 # Generate initial array mod Z A = [0]*(N+1) # 1-based indexing A[1] = S % Z for i in range(2, N+1): A[i] = (X * A[i-1] + Y) % Z # Convert to binary (parity) binary = [0]*(N+1) for i in range(1, N+1): binary[i] = A[i] % 2 for _ in range(Q): if ptr >= len(input): S_op = 0 else: 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 L = T_op - S_op + 1 # Make a copy of B B = [binary[i] for i in range(S_op, T_op+1)] # Apply to [U, V] for k in range(U_op, V_op+1): offset = k - U_op s_pos = S_op + offset if s_pos < S_op or s_pos > T_op: continue # shouldn't happen binary[k] ^= B[offset] # Build the result string res = [] for i in range(1, N+1): if binary[i] == 0: res.append('E') else: res.append('O') print(''.join(res)) if __name__ == '__main__': main()