#include typedef struct dot { int x; int y; int r_num; } Dot; int main() { int dot_num = 0; int initial_x, initial_y; scanf("%d%d%d", &dot_num, &initial_x, &initial_y); Dot dots[dot_num]; int command[dot_num][2]; for (int j = 0; j < dot_num; ++j) { dots[j].x = initial_x; dots[j].y = initial_y; dots[j].r_num = 0; scanf("%d", &command[j][0]); if (command[j][0] == 3) { continue; } scanf("%d", &command[j][1]); } for (int k = 0; k < dot_num; ++k) { for (int i = k; i < dot_num; ++i) { switch (command[i][0]) { case 1: dots[k].x += command[i][1]; break; case 2: dots[k].y += command[i][1]; break; case 3: dots[k].r_num++; } } } for (int k = 0; k < dot_num; ++k) { switch (dots[k].r_num % 4) { case 1: { int temp = dots[k].x; dots[k].x = dots[k].y; dots[k].y = -temp; break; } case 2: { dots[k].x = -dots[k].x; break; } case 3: { int temp = dots[k].x; dots[k].x = -dots[k].y; dots[k].y = temp; break; } } } for (int l = 0; l < dot_num; ++l) { printf("%d %d\n", dots[l].x, dots[l].y); } return 0; }