#include #include #include #include #include #include #include #include #include #include #include using namespace std; #define SZ 1200 //#define DBG_ void init(vector> &v, int n, int s, long long x, long long y, long long z){ vector a(n, 1); a[0] = s; v[0/SZ].set(0%SZ, a[0]&1); for(int i=1; i x){ string s = x.to_string(); cerr << s << endl; } int main(){ int n,s,x,y,z; cin >> n >> s >> x >> y >> z; int k = n/SZ + 1; vector> vec(k); init(vec,n,s,x,y,z); #ifdef DBG_ for(int i=0; i> q; while(q-->0){ int s_, t, u, v; scanf("%d %d %d %d", &s_, &t, &u, &v); s_--; t--; u--; v--; vector> tmp(vec.begin() + s_/SZ , vec.begin() + (t+1)/SZ + 1); #ifdef DBG_ cerr << "tmp " << endl; for(int i=0; i>= s_%SZ; tmp[0] <<= s_%SZ; #ifdef DBG_ cerr << "tmp s " << endl; for(int i=0; i>= SZ-((t+1)%SZ); #ifdef DBG_ cerr << "tmp t " << endl; for(int i=0; i> abs(d)); if(i+10){ vec[u/SZ + i] ^= (tmp[i] << abs(d)); if(i>0){ vec[u/SZ + i] ^= ( tmp[i-1] >> (SZ - abs(d)) ); } } #ifdef DBG_ cerr << "to :" << endl; dbg(vec[u/SZ+i]); cerr << endl; #endif } if(d>0 && u/SZ + tmp.size() < vec.size() ){ vec[u/SZ + tmp.size()] ^= ( tmp[tmp.size()-1] >> (SZ - abs(d)) ); } #ifdef DBG_ cerr << "res " << endl; for(int i=0; i