#include #define rep(i,a,b) for(int i=a;i=b;i--) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(),(x).end() //#pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b; using Mat = vector; Vec mulMatVec(Mat a, Vec b) { int n = b.size(); Vec ret(n, 0); rep(i, 0, n) rep(j, 0, n) ret[i] = ret[i] + a[i][j] * b[j]; return ret; } Vec mulVecMat(Vec a, Mat b) { int n = b.size(); Vec ret(n, 0); rep(i, 0, n) rep(j, 0, n) ret[i] = ret[i] + a[j] * b[j][i]; return ret; } Mat identityMat(int n) { Mat m(n, Vec(n, 0)); rep(i, 0, n) m[i][i] = 1; return m; } Mat mulMatMat(Mat a, Mat b) { int n = a.size(); Mat ret(n, Vec(n, 0)); rep(i, 0, n) rep(j, 0, n) rep(k, 0, n) ret[i][j] = ret[i][j] + a[i][k] * b[k][j]; return ret; } Mat fastpow(Mat x, ll n) { Mat ret(x.size(), Vec(x.size(), 0)); rep(i, 0, x.size()) ret[i][i] = 1; while (0 < n) { if ((n % 2) == 0) { x = mulMatMat(x, x); n >>= 1; } else { ret = mulMatMat(ret, x); --n; } } return ret; } void printVec(Vec a) { cout << "[\t"; rep(i, 0, a.size()) cout << a[i] << "\t"; cout << "]" << endl; } void printMat(Mat a) { rep(i, 0, a.size()) printVec(a[i]); } /*---------------------------------------------------------------------------------------------------             ∧_∧       ∧_∧  (´<_` )  Welcome to My Coding Space!      ( ´_ゝ`) /  ⌒i @hamayanhamayan     /   \    | |     /   / ̄ ̄ ̄ ̄/  |   __(__ニつ/  _/ .| .|____      \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ ll N, Px, Py, T[101010], X[101010]; Mat ms[101010]; //--------------------------------------------------------------------------------------------------- Mat command1(ll dx) { return { {1, 0, dx}, {0, 1, 0}, {0, 0, 1} }; } Mat command2(ll dy) { return { {1, 0, 0}, {0, 1, dy}, {0, 0, 1} }; } Mat command3() { return { {0, 1, 0}, // cos(-90), -sin(-90) {-1, 0, 0}, // sin(-90), cos(-90) {0, 0, 1} }; } //--------------------------------------------------------------------------------------------------- void _main() { cin >> N >> Px >> Py; rep(i, 0, N) { cin >> T[i]; if (T[i] != 3) cin >> X[i]; } ms[N] = identityMat(3); rrep(i, N - 1, 0) { Mat m; if (T[i] == 1) m = command1(X[i]); else if (T[i] == 2) m = command2(X[i]); else m = command3(); ms[i] = mulMatMat(ms[i + 1], m); } rep(i, 0, N) { Vec v = { Px, Py, 1 }; v = mulMatVec(ms[i], v); printf("%lld %lld\n", v[0], v[1]); } }