#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { int i, j, k; int n; long x, y; vector>c, d; cin >> n >> x >> y; for (i = 0; i < n; i++) { long num; cin >> num; if (num == 1 || num == 2) { long num2; cin >> num2; c.push_back(make_pair(num, num2)); } else { c.push_back(make_pair(num, -1)); } } int four = 4; long xx = x, yy = y; for (i = n - 1; i >= 0; i--) { if (c[i].first == 3) { //if (four % 4 == 0) { if (xx > 0) { if (yy > 0) { d.push_back(make_pair(yy, -xx)); four++; long swp = xx; xx = yy; yy = -swp; } else if (yy <= 0) { //d.push_back(make_pair(-yy, -xx)); d.push_back(make_pair(yy, -xx)); four++; long swp = xx; xx = yy; yy = -swp; } } else if (xx <= 0) { if (yy > 0) { //d.push_back(make_pair(yy, xx)); d.push_back(make_pair(yy, abs(xx) )); four++; long swp = abs( xx ); xx = yy; yy = swp; } else if (yy <= 0) { //d.push_back(make_pair(-yy, xx)); d.push_back(make_pair(yy, abs(xx))); four++; long swp = abs(xx); xx = yy; yy = swp; } } //} } else if (c[i].first == 1) { if (four % 4 == 1) { yy -= c[i].second; } else if (four % 4 == 2) { xx -= c[i].second; } else if (four % 4 == 3) { yy += c[i].second; } else if (four % 4 == 0) { xx += c[i].second; } d.push_back(make_pair( xx, yy)); } else if (c[i].first == 2) { if (four % 4 == 1) { xx += c[i].second; } else if (four % 4 == 2) { yy -= c[i].second; } else if (four % 4 == 3) { xx -= c[i].second; } else if (four % 4 == 0) { yy += c[i].second; } d.push_back(make_pair(xx, yy)); } } for (i = n - 1; i >= 0; i--) { cout << d[i].first << " " << d[i].second << endl; } getchar(); getchar(); return 0; }