using System; using System.IO; using System.Linq; using System.Text; using System.Collections.Generic; using System.Diagnostics; using System.Numerics; using Enu = System.Linq.Enumerable; using System.Collections; using System.Runtime.CompilerServices; class Program { public void Solve() { long N = Reader.Int(), S = Reader.Int(); long X = Reader.Int(), Y = Reader.Int(), Z = Reader.Int(); int Q = Reader.Int(); var table = Reader.IntTable(Q); var A = new long[(N + BitW - 1) / BitW + 1]; var tmp = new long[(MaxRange + BitW - 1) / BitW + 1]; for (int i = 0; i < N; i++) { A[i / BitW] |= (S & 1) << (i & BitW - 1); S = (S * X + Y) % Z; } foreach (var row in table) { int fromL = row[0] - 1, len = row[1] - fromL, toL = row[2] - 1; RangeXor(A, A, fromL, toL, len); } var ans = new StringBuilder(); for (int i = 0; i < N; i++) ans.Append((A[i / BitW] >> (i % BitW) & 1) == 1 ? 'O' : 'E'); Console.WriteLine(ans); } static readonly int BitW = 64; static readonly int MaxRange = (int)2e5; static long[] tmp = new long[MaxRange / BitW + 10]; static void RangeXor(long[] A, long[] B, int fromL, int toL, int len) { Func GetMask = n => n == 64 ? -1L : (1L << n) - 1; int fromR = fromL + len - 1; int ai = fromL / BitW, aleft = fromL % BitW, alast = fromR / BitW; int bleft = toL % BitW; int firstAlen = Math.Min(len, BitW - aleft); int firstBlen = Math.Min(len, BitW - bleft); int firstLen = Math.Min(firstAlen, firstBlen); int ti = 0; tmp[ti] = (A[ai] >> aleft & GetMask(firstLen)) << bleft; int LBshift = bleft + firstLen; if (bleft + firstLen == BitW) { LBshift = firstAlen - firstBlen; tmp[++ti] = A[ai] >> aleft + firstLen & GetMask(LBshift); } ai++; long Lmask = GetMask(BitW - LBshift); int RAshift = BitW - LBshift; long Rmask = GetMask(LBshift); for (; ai < alast; ai++) { tmp[ti] |= (A[ai] & Lmask) << LBshift; tmp[++ti] = A[ai] >> RAshift & Rmask; } if (ai == alast) { int lastLen = fromR - ai * BitW + 1; int Llen = Math.Min(lastLen, BitW - LBshift); int Rlen = lastLen - Llen; tmp[ti] |= (A[ai] & GetMask(Llen)) << LBshift; if (Rlen > 0) tmp[++ti] = A[ai] >> Llen & GetMask(Rlen); } for (int i = 0, bi = toL / BitW; i <= ti; i++, bi++) B[bi] ^= tmp[i]; } } class Entry { static void Main() { new Program().Solve(); } } class Reader { private static TextReader reader = Console.In; private static readonly char[] separator = { ' ' }; private static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries; private static string[] A = new string[0]; private static int i; private static void Init() { A = new string[0]; } public static void Set(TextReader r) { reader = r; Init(); } public static void Set(string file) { reader = new StreamReader(file); Init(); } public static bool HasNext() { return CheckNext(); } public static string String() { return Next(); } public static int Int() { return int.Parse(Next()); } public static long Long() { return long.Parse(Next()); } public static double Double() { return double.Parse(Next()); } public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); } public static int[] IntArray(int N) { return Enu.Range(0, N).Select(i => Int()).ToArray(); } public static int[][] IntTable(int H) { return Enu.Range(0, H).Select(i => IntLine()).ToArray(); } public static string[] StringArray(int N) { return Enu.Range(0, N).Select(i => Line()).ToArray(); } public static string Line() { return reader.ReadLine().Trim(); } private static string[] Split(string s) { return s.Split(separator, op); } private static string Next() { CheckNext(); return A[i++]; } private static bool CheckNext() { if (i < A.Length) return true; string line = reader.ReadLine(); if (line == null) return false; if (line == "") return CheckNext(); A = Split(line); i = 0; return true; } }