#include // c #include // io #include #include #include #include // container #include #include #include #include #include #include // other #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; #define ALL(c) (begin(c)),(end(c)) #define REP(i,n) FOR(i,0,n) #define REPr(i,n) FORr(i,0,n) #define FOR(i,l,r) for(int i=(int)(l);i<(int)(r);++i) #define FORr(i,l,r) for(int i=(int)(r)-1;i>=(int)(l);--i) #define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it) #define IN(l,v,r) ((l)<=(v) && (v)<(r)) #define UNIQUE(v) v.erase(unique(ALL(v)),v.end()) //debug #define DUMP(x) cerr << #x << " = " << (x) #define LINE() cerr<< " (L" << __LINE__ << ")" class range { private: struct Iter{ int v; int operator*(){return v;} bool operator!=(Iter& itr) {return v < itr.v;} void operator++() {++v;} }; Iter i, n; public: range(int n) : i({0}), n({n}) {} range(int i, int n) : i({i}), n({n}) {} Iter& begin() {return i;} Iter& end() {return n;} }; //input template istream& operator >> (istream& is,pair& p){return is>>p.first>>p.second;} template istream& operator >> (istream& is,tuple& t){return is >> get<0>(t);} template istream& operator >> (istream& is,tuple& t){return is >> get<0>(t) >> get<1>(t);} template istream& operator >> (istream& is,tuple& t){return is >>get<0>(t)>>get<1>(t)>>get<2>(t);} template istream& operator >> (istream& is,tuple& t){return is >> get<0>(t)>>get<1>(t)>>get<2>(t)>>get<3>(t);} template istream& operator >> (istream& is, const tuple& t){return is >> get<0>(t) >> get<1>(t) >> get<2>(t) >> get<3>(t) >> get<4>(t);} template istream& operator >> (istream& is, const tuple& t){return is >> get<0>(t) >> get<1>(t) >> get<2>(t) >> get<3>(t) >> get<4>(t) >> get<5>(t);} template istream& operator >> (istream& is, const tuple& t){return is >> get<0>(t) >> get<1>(t) >> get<2>(t) >> get<3>(t) >> get<4>(t) >> get<5>(t) >> get<6>(t);} template istream& operator >> (istream& is,vector& as){for(int i:range(as.size()))is >>as[i];return is;} //output template ostream& operator << (ostream& os, const set& ss){for(auto a:ss){if(a!=ss.begin())os<<" "; os< ostream& operator << (ostream& os, const pair& p){os< ostream& operator << (ostream& os, const map& m){bool isF=true;for(auto& p:m){if(!isF)os< ostream& operator << (ostream& os, const tuple& t){return os << get<0>(t);} template ostream& operator << (ostream& os, const tuple& t){return os << get<0>(t)<<" "<(t);} template ostream& operator << (ostream& os, const tuple& t){return os << get<0>(t)<<" "<(t)<<" "<(t);} template ostream& operator << (ostream& os, const tuple& t){return os << get<0>(t)<<" "<(t)<<" "<(t)<<" "<(t);} template ostream& operator << (ostream& os, const tuple& t){return os << get<0>(t)<<" "<(t)<<" "<(t)<<" "<(t)<<" "<(t);} template ostream& operator << (ostream& os, const tuple& t){return os << get<0>(t)<<" "<(t)<<" "<(t)<<" "<(t)<<" "<(t)<<" "<(t);} template ostream& operator << (ostream& os, const tuple& t){return os << get<0>(t)<<" "<(t)<<" "<(t)<<" "<(t)<<" "<(t)<<" "<(t)<<" "<(t);} template ostream& operator << (ostream& os, const vector& as){for(int i:range(as.size())){if(i!=0)os<<" "; os< ostream& operator << (ostream& os, const vector>& as){for(int i:range(as.size())){if(i!=0)os< T INF(){assert(false);}; template<> int INF(){return 1<<28;}; template<> ll INF(){return 1LL<<58;}; template<> double INF(){return 1e16;}; template<> long double INF(){return 1e16;}; template T EPS(){assert(false);}; template<> int EPS(){return 1;}; template<> ll EPS(){return 1LL;}; template<> double EPS(){return 1e-8;}; template<> long double EPS(){return 1e-8;}; template T pmod(T v,U M){return (v%M+M)%M;} ll gcd_positive(ll a,ll b) { return b == 0 ? a : gcd_positive(b,a%b); } ll gcd(ll a,ll b) { return gcd_positive(abs(a), abs(b)); } ll lcm(ll a,ll b){return a/gcd(a,b)*b;} // struct BitSet{ // const static int B=64; // vector bit; // BitSet(int N){ // bit=vector(N/B); // } // bool operator[](int i)const{ // return bit[i/B]&(1<<(i%B)); // } // inline BitSet bitXOR(BitSet& b,int sa,int sb,int len) const{// [l,r) // { // int pa=sa/B; // for(int pb:range(0,len/B + 1)){ // b.bit[pb]=(this->bit[pa++])>>(sa%B); // if(sa%B) b.bit[pb] |= this->bit[pa]<<(B-sa%B); // } // b.bit[len/B] &= (len%B); // } // { // int pa=sb/B; // for(int pa:range(0,len/B + 1)){ // this->bit[pa++] ^= b.bit[pa]>>(sa%B); // if(sa%B) b.bit[pb] |= this->bit[pa]<<(B-sa%B); // } // b.bit[len/B] &= (len%B); // } // return a; // } // BitSet operator |= (const BitSet& r) const{ // } // }; class Main{ public: void run(){ int N;ll S,X,Y,Z;cin >> N >> S >> X >> Y >> Z; vector as(N);as[0]=S; for(int i:range(1,N)){ as[i]=(X*as[i-1]+Y)%Z; } REP(i,N)as[i]%=2; vector mask(65); for(int i:range(0,64))mask[i+1]=mask[i]|(1< maskr(65); for(int i:range(65))maskr[i]=mask[64]^mask[i]; int B=60; vector bs(N/B+3); REP(i,N) bs[i/B]|=as[i]<<(i%B); int Q;cin >> Q; REP(q,Q){ int s,t,u,v;cin >> s >> t >> u >> v;s--;u--; if(s>u){ while(s>(sb)) <<(ub); s+=len;u+=len; } }else{ while(s>(tb-len))<<((v-len)%B); t-=len;v-=len; } } // REP(i,N)as[i]=(bs[i/B]>>(i%B))&1; // string res=""; // REP(i,N)res+=as[i]?'O':'E'; // cout << res <>(i%B))&1; string res=""; REP(i,N)res+=as[i]?'O':'E'; cout << res <