#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}; /*================================*/ int N,X,Y; struct Order{int c; int v;}; struct Pos { int x, y; Pos(){}; Pos(int _x, int _y): x(_x), y(_y){}; Pos operator * (int t) { return Pos(t * x, t * y); } Pos operator + (Pos q) { return Pos(x + q.x, y + q.y); } Pos operator - (Pos q) { return Pos(x - q.x, y - q.y); } int dot(Pos q) { return x * q.x + y * q.y; } int det(Pos q) { return x * q.y - y * q.x; } bool operator == (Pos q) { return (x == q.x) && (y == q.y); } void rotate() { int tmp = y; y = -x; x = tmp; } void rotate2() { int tmp = x; x = -y; y = tmp; } }; 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; Pos pos(X, Y); Pos c1(1, 0); Pos c2(0, 1); REP(i,N) { cin>>c; if (c<3) cin>>v; if (c == 1) { pos = pos + c1 * v; } if (c==2) { pos = pos + c2 * v; } if (c==3){ pos.rotate(); c1.rotate(); c2.rotate(); } O[i].c = c; O[i].v = v; } c1 = c1 * -1; c2 = c2 * -1; REP(i,N) { out("%lld %lld\n", pos.x, pos.y); auto o = O[i]; if (o.c == 1) { pos = pos + c1 * o.v; } if (o.c==2) { pos = pos + c2 * o.v; } if (o.c==3){ pos.rotate2(); c1.rotate2(); c2.rotate2(); } } return 0; }