#include using namespace std; template using vec = vector; using mat = vec>; mat operator *(mat a, mat b) { mat c = mat(a.size(), vec(b[0].size())); for (int i = 0; i < a.size(); ++i) { for (int k = 0; k < b.size(); ++k) { for (int j = 0; j < b[0].size(); ++j) { c[i][j] += a[i][k] * b[k][j]; } } } return c; } signed main() { ios::sync_with_stdio(false); int N, Px, Py; cin >> N >> Px >> Py; mat x = mat(3, vec(1)); x[0][0] = Px; x[1][0] = Py; x[2][0] = 1; mat prod_t = mat(3, vec(3)); for (int i = 0; i < 3; ++i) { prod_t[i][i] = 1; } vector OP; for (int i = 0; i < N; ++i) { int op; cin >> op; if (op < 3) { int u; cin >> u; OP.emplace_back(u); } OP.emplace_back(op); } reverse(OP.begin(), OP.end()); vector> ans(N); for (int i = 0, ptr = 0; i < N; ++i) { int op = OP[ptr++]; mat t = mat(3, vec(3)); if (op == 1) { int Dx = OP[ptr++]; for (int j = 0; j < 3; ++j) { t[j][j] = 1; } t[0][2] = Dx; } else if (op == 2) { int Dy = OP[ptr++]; for (int j = 0; j < 3; ++j) { t[j][j] = 1; } t[1][2] = Dy; } else { t[0][1] = 1; t[1][0] = -1; t[2][2] = 1; } prod_t = prod_t * t; mat res = prod_t * x; ans[N - 1 - i] = make_pair(res[0][0], res[1][0]); } for (int i = 0; i < ans.size(); ++i) { cout << ans[i].first << ' ' << ans[i].second << endl; } return 0; }