#include "bits/stdc++.h" using namespace std; #define int long long #define FOR(i, a, b) for(int i=(a);i<(b);i++) #define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--) #define REP(i, n) for(int i=0; i<(n); i++) #define RREP(i, n) for(int i=(n-1); i>=0; i--) #define ALL(a) (a).begin(),(a).end() #define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end()); #define CONTAIN(a, b) find(ALL(a), (b)) != (a).end() #define array2(type, x, y) array, x> #define vector2(type) vector > #define out(...) printf(__VA_ARGS__) int dxy[] = {0, 1, 0, -1, 0}; /*================================*/ template struct Pos { T x, y, z; Pos(){}; Pos(T _x, T _y): x(_x), y(_y){}; Pos(T _x, T _y, T _z): x(_x), y(_y), z(_z){}; Pos operator * (T t) { return Pos(t * x, t * y, t * z); } Pos operator + (Pos q) { return Pos(x + q.x, y + q.y, z + q.z); } Pos operator - (Pos q) { return Pos(x - q.x, y - q.y, z - q.z); } int dot(Pos q) { return x*q.x + y*q.y + z*q.z; } Pos det(Pos q) { return Pos( y*q.z - z*q.y , z*q.x - x*q.z , x*q.y - y*q.x ); } bool operator == (Pos q) { return (x == q.x) && (y == q.y) && (z == q.z); } Pos operator * ( const Pos& q ) { return det(q); } T operator % ( const Pos& q ) { return dot(q); } T norm() { return sqrt(x*x + y*y + z*z); } }; template struct Matrix { Pos a[3]; // 行ごと Matrix(T a0, T a1, T a2, T b0, T b1, T b2, T c0, T c1, T c2) { a[0] = *new Pos(a0, a1, a2); a[1] = *new Pos(b0, b1, b2); a[2] = *new Pos(c0, c1, c2); } Pos operator * (Pos v) { return *new Pos(a[0].dot(v), a[1].dot(v), a[2].dot(v)); } Pos & operator[](int i) { return a[i]; } Pos col(int i) { int Pos::*p=(i==0) ? &Pos::x : (i==1) ? &Pos::y : &Pos::z; return *new Pos(a[0].*p, a[1].*p, a[2].*p); } Matrix operator * ( Matrix& q ) { return *new Matrix( a[0]%q.col(0), a[0]%q.col(1), a[0]%q.col(2), a[1]%q.col(0), a[1]%q.col(1), a[1]%q.col(2), a[2]%q.col(0), a[2]%q.col(1), a[2]%q.col(2) ); } }; int N,X,Y; struct Order{int c; int v;}; signed main() { #if DEBUG std::ifstream in("input.txt"); std::cin.rdbuf(in.rdbuf()); #endif cin>>N>>X>>Y; vector O(N); int c=0,v=0; REP(i,N) { cin>>c; if (c<3) cin>>v; O[i].c = c; O[i].v = v; } auto rotate = Matrix(0,1,0, -1,0,0, 0,0,1); auto convert = Matrix(1,0,0, 0,1,0, 0,0,1); vector> ans; RREP(i,N) { int c = O[i].c, v = O[i].v; if (c == 1) { auto move = Matrix(1,0,v, 0,1,0, 0,0,1); convert = convert * move; } if (c==2) { auto move = Matrix(1,0,0, 0,1,v, 0,0,1); convert = convert * move; } if (c==3){ convert = convert * rotate; } auto pos = convert * Pos(X, Y, 1); ans.push_back(pair(pos.x, pos.y)); } reverse(ALL(ans)); for (auto a : ans) { out("%lld %lld\n", a.first, a.second); } return 0; }