#include int main() { std::cin.tie(0); std::ios::sync_with_stdio(false); int N, Px, Py; std::cin >> N >> Px >> Py; int rot = 0, dx = 0, dy = 0; auto move = [&](const int Dx, const int Dy) { if (rot == 0) { dx += Dx, dy += Dy; } else if (rot == 1) { dx += Dy, dy -= Dx; } else if (rot == 2) { dx -= Dx, dy -= Dy; } else { dx -= Dy, dy += Dx; } }; using P = std::pair; using PP = std::pair; std::vector

ans; auto answer = [&]() { int X, Y; if (rot == 0) { X = Px, Y = Py; } else if (rot == 1) { X = Py, Y = -Px; } else if (rot == 2) { X = -Px, Y = -Py; } else { X = -Py, Y = Px; } ans.push_back({X + dx, Y + dy}); }; std::vector com; for (int i = 0; i < N; i++) { int Com, Dx = 0, Dy = 0; std::cin >> Com; if (Com == 1) { std::cin >> Dx; } else if (Com == 2) { std::cin >> Dy; } com.push_back({Com == 3, {Dx, Dy}}); } std::reverse(com.begin(), com.end()); for (const auto& c : com) { if (c.first) { (rot += 1) %= 4; } else { move(c.second.first, c.second.second); } answer(); } std::reverse(ans.begin(), ans.end()); for (const auto& p : ans) { std::cout << p.first << " " << p.second << std::endl; } return 0; }