#define NDEBUG #undef __STRICT_ANSI__ #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #undef assert #define assert(e) #include typedef long long int64; #include class XsRandom { unsigned long long a; unsigned long long b; public: inline XsRandom() : a(0x8a5cd789635d2dffULL), b(0x121fd2155c472f96ULL) { } inline XsRandom(const XsRandom & o) : a(o.a), b(o.b) { } inline unsigned long long next64() { unsigned long long c = a ^ (a<<23); a = b; b = c ^ a ^ (c>>18) ^ (a>>5); return b + a; } inline XsRandom(unsigned int seed) : a(0x8a5cd789635d2dffULL), b(0x121fd2155c472f96ULL) { seed = seed * 1234567891 + 521288629; unsigned long long a2 = a; unsigned long long b2 = b; while(seed) { next64(); if(seed & 1) { a2 ^= a; b2 ^= b; } seed >>= 1; } a = a2; b = b2; } inline unsigned int next() { return (unsigned int)next64(); } inline int nextInt(int r) { assert(1<=r); return ((unsigned long long)next() * r)>>32; } }; typedef XsRandom MyRandom; MyRandom g_myRand; double g_startTime; double g_suspendTime = 0; const double g_timeupSecBase = 9.8; double g_timeupSec = g_timeupSecBase; #include const char * nextCLineOrWord(int mode) { static char buf[65536]; static int bufLen = sizeof(buf); static int bufPos = sizeof(buf); static bool canReadFlag = true; static bool crFlag = false; static bool enterFlag = false; if(mode==0) { while(true) { char c = buf[bufPos]; if(c==32 || c==10 || c==13) { ++bufPos; } else { break; } } } if(canReadFlag && (enterFlag ? bufLen<=bufPos : (int)sizeof(buf)<=bufPos+bufPos)) { if(0 nextIntVec(int n) { vector ret; for(int i=0; i nextInt64Vec(int n) { vector ret; for(int i=0; i > A; map, greater > B; vector a0 = nextInt64Vec(3); vector bn = nextInt64Vec(2); int q = nextInt(); for(int j=0; j a = a0; for(auto & o : A) { if(i<=o.first) { break; } auto & x = o.second; int64 a1 = x[0] * a[0] + x[1] * a[1] + x[2] * a[2]; int64 a2 = x[3] * a[0] + x[4] * a[1] + x[5] * a[2]; int64 a3 = x[6] * a[0] + x[7] * a[1] + x[8] * a[2]; a[0] = a1 % 1000000007; a[1] = a2 % 1000000007; a[2] = a3 % 1000000007; } echoln("%d %d %d", (int)a[0], (int)a[1], (int)a[2]); fflush(stdout); } else if(w=="gb") { int i = nextInt(); vector a = a0; vector > > AA; AA.emplace_back(-1, a); AA.emplace_back(-1, a); for(auto & o : A) { AA.emplace_back(o.first, a); auto & x = o.second; int64 a1 = x[0] * a[0] + x[1] * a[1] + x[2] * a[2]; int64 a2 = x[3] * a[0] + x[4] * a[1] + x[5] * a[2]; int64 a3 = x[6] * a[0] + x[7] * a[1] + x[8] * a[2]; a[0] = a1 % 1000000007; a[1] = a2 % 1000000007; a[2] = a3 % 1000000007; } vector b = bn; int64 t = n; for(auto & o : B) { if(!(i