#include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; typedef vector vec; typedef vector mat; mat mul(mat &A, mat &B){ mat C(A.size(), vec(B[0].size())); rep(i,A.size()) rep(k,B.size()){ rep(j,B[0].size()){ C[i][j] = (C[i][j]+A[i][k]*B[k][j]); } } return C; } vector mulv(mat &A, vector v){ vector ret = v; rep(i,v.size()){ ll res = 0; rep(j,v.size()){ res += A[i][j]*v[j]; } ret[i] = res; } return ret; } int main(){ int N; ll Px, Py; cin >> N >> Px >> Py; vector> commands; rep(i,N){ ll type; cin >> type; if(type == 1){ ll Dx; cin >> Dx; commands.push_back({1,Dx}); } else if(type == 2){ ll Dy; cin >> Dy; commands.push_back({2,Dy}); } else { commands.push_back({3,-1}); } } mat P = {{1,0,0},{0,1,0},{0,0,1}}; vector> pos; for(int i=commands.size()-1; i>=0; i--){ mat X; if(commands[i][0] == 1){ X = {{1,0,commands[i][1]},{0,1,0},{0,0,1}}; } else if(commands[i][0] == 2){ X = {{1,0,0},{0,1,commands[i][1]},{0,0,1}}; } else{ X = {{0,1,0},{-1,0,0},{0,0,1}}; } P = mul(P, X); vec st = {Px, Py, 1}; vec ret = mulv(P, st); pos.push_back({ret[0],ret[1]}); } reverse(ALLOF(pos)); rep(i,pos.size()){ cout << pos[i][0] << " " << pos[i][1] << endl; } return 0; }