#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define forr(x,arr) for(auto&& x:arr) #define _overload3(_1,_2,_3,name,...) name #define _rep2(i,n) _rep3(i,0,n) #define _rep3(i,a,b) for(int i=int(a);i=int(a);i--) #define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__) #define all(x) (x).begin(),(x).end() #define bit(n) (1LL<<(n)) #define sz(x) ((int)(x).size()) #define TEN(n) ((ll)(1e##n)) #define fst first #define snd second string DBG_DLM(int &i){return(i++==0?"":", ");} #define DBG_B(exp){int i=0;os<<"{";{exp;}os<<"}";return os;} templateostream&operator<<(ostream&os,vectorv); templateostream&operator<<(ostream&os,setv); templateostream&operator<<(ostream&os,queueq); templateostream&operator<<(ostream&os,priority_queueq); templateostream&operator<<(ostream&os,pairp); templateostream&operator<<(ostream&os,mapmp); templateostream&operator<<(ostream&os,unordered_mapmp); templatevoid DBG(ostream&os,TPL t){} templatevoid DBG(ostream&os,TPL t){os<<(I==0?"":", ")<(t);DBG(os,t);} templatevoid DBG(ostream&os,pairp,string delim){os<<"("<ostream&operator<<(ostream&os,tuplet){os<<"(";DBG<0,tuple,Ts...>(os,t);os<<")";return os;} templateostream&operator<<(ostream&os,pairp){DBG(os,p,", ");return os;} templateostream&operator<<(ostream&os,vectorv){DBG_B(forr(t,v){os<ostream&operator<<(ostream&os,sets){DBG_B(forr(t,s){os<ostream&operator<<(ostream&os,queueq){DBG_B(for(;q.size();q.pop()){os<ostream&operator<<(ostream&os,priority_queueq){DBG_B(for(;q.size();q.pop()){os<ostream&operator<<(ostream&os,mapm){DBG_B(forr(p,m){os<");});} templateostream&operator<<(ostream&os,unordered_mapm){DBG_B(forr(p,m){os<");});} #define DBG_OVERLOAD(_1,_2,_3,_4,_5,_6,macro_name,...)macro_name #define DBG_LINE(){char s[99];sprintf(s,"line:%3d | ",__LINE__);cerr<;using pll=pair;using pil=pair;using pli=pair; using vs=vector;using vvs=vector;using vvvs=vector; using vb=vector;using vvb=vector;using vvvb=vector; using vi=vector;using vvi=vector;using vvvi=vector; using vl=vector;using vvl=vector;using vvvl=vector; using vd=vector;using vvd=vector;using vvvd=vector; using vpii=vector;using vvpii=vector;using vvvpii=vector; templatebool amax(A&a,const B&b){return b>a?a=b,1:0;} templatebool amin(A&a,const B&b){return b>l;return l;} string rs(){string s;cin>>s;return s;} template struct matrix_ { array val; matrix_(vector> ini) { for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) val[i * N + j] = ini[i][j]; } matrix_(int d = 0) { for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) val[i * N + j] = T((i == j) * d); } matrix_ operator+(const matrix_ &x) const { matrix_ ret; for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) { ret.val[i * N + j] = val[i * N + j] + x.val[i * N + j]; } return ret; } matrix_ operator*(const matrix_ &x) const { matrix_ ret; for (int i = 0; i < N; i++) for (int k = 0; k < N; k++) for (int j = 0; j < N; j++) { ret.val[i * N + j] += val[i * N + k] * x.val[k * N + j]; } return ret; } vector operator*(const vector &v) const { vector ret(N); for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) { ret[i] += val[i * N + j] * v[j]; } return ret; } matrix_ operator^(unsigned long long p) const { matrix_ ret(1); matrix_ x(*this); while (p) { if (p & 1) ret = ret * x; x = x * x; p >>= 1; } return ret; } T& at(int row, int col) { return val[row * N + col]; } const T& at(int row, int col) const { return val[row * N + col]; } }; template ostream& operator<<(ostream& os, const matrix_& mat) { vector> vec(N, vector(N)); for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) vec[i][j] = mat.at(i, j); os << vec; return os; } using Mat = matrix_; const Mat ini(1); template struct SegmentTree { const int n; const V unit_value; vector val; SegmentTree(int _n) : n(1 << (32-__builtin_clz(_n-1))), unit_value(Merge::unit()), val(n * 2, unit_value) {} V get(int i) const { return val[i + n]; } void set(int i, const V &v) { val[i + n] = v; } void build() { for (int i = n - 1; i > 0; i--) val[i] = Merge::merge(val[i << 1], val[i << 1 | 1]); } void update(int i, const V &v) { i += n; val[i] = v; while (i > 1) { i >>= 1; val[i] = Merge::merge(val[i << 1], val[i << 1 | 1]); } } V query(int l, int r) const { l = max(0, min(n, l)) + n; r = max(0, min(n, r)) + n; V ret1 = unit_value, ret2 = unit_value; while (l < r) { if (l & 1) ret1 = Merge::merge(ret1, val[l++]); if (r & 1) ret2 = Merge::merge(val[--r], ret2); l >>= 1; r >>= 1; } return Merge::merge(ret1, ret2); } }; template ostream& operator<<(ostream& os, const SegmentTree& seg) { vector vec; for (int i = 0; i < seg.n; i++) { vec.emplace_back(seg.get(i)); } os << vec; return os; } struct Merge { static Mat merge(const Mat &l, const Mat &r) { return r * l; } static Mat unit() { return ini; } }; void Main() { int n = ri(); ll px = ri(), py = ri(); SegmentTree seg(n); Mat rot = Mat({{0,1,0},{-1,0,0},{0,0,1}}); rep(i, n) { int t = ri(); if (t == 3) { seg.set(i, rot);; } else { int a = ri(); if (t == 1) { seg.set(i, Mat({{1,0,a},{0,1,0},{0,0,1}})); } else { seg.set(i, Mat({{1,0,0},{0,1,a},{0,0,1}})); } } } seg.build(); vl p{px, py, 1}; rep(i, n) { Mat trans = seg.query(i, n); vl ans = trans * p; cout << ans[0] << ' ' << ans[1] << endl; } } signed main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }