// yukicoder: 675 ドットちゃんたち // 2019.8.18 bal4u #include #if 1 #define gc() getchar_unlocked() #define pc(c) putchar_unlocked(c) #else #define gc() getchar() #define pc(c) putchar(c) #endif int in() { // 整数の入力(負数対応) int n = 0, c = gc(); if (c == '-') { c = gc(); do n = 10*n + (c & 0xf), c = gc(); while (c >= '0'); return -n; } do n = 10*n + (c & 0xf), c = gc(); while (c >= '0'); return n; } void out(int n) { // 整数の表示(出力) int i; char b[30]; if (!n) pc('0'); else { if (n < 0) pc('-'), n = -n; i = 0; while (n) b[i++] = n % 10 + '0', n /= 10; while (i--) pc(b[i]); } } int x[100003], y[100003], r[100003]; int X, Y, R; void rot(int dx, int dy, int r) { if (r == 0) X += dx, Y += dy; else if (r == 1) X -= dy, Y += dx; else if (r == 2) X -= dx, Y -= dy; else X += dy, Y -= dx; } void pr(int x, int y, int r) { int xx, yy; if (r == 0) xx = x, yy = y; else if (r == 1) xx = -y, yy = x; else if (r == 2) xx = -x, yy = -y; else xx = y, yy = -x; out(xx), pc(' '), out(yy), pc('\n'); } int main() { int i, N, Px, Py, Nx, Ny, Nr; N = in(), Px = in(), Py = in(); for (i = 1; i <= N; i++) { int cmd, dx, dy; cmd = gc() & 3, gc(); if (cmd != 3) { if (cmd == 1) dx = in(), dy = 0; else dx = 0, dy = in(); rot(dx, dy, R); } else if (++R == 4) R = 0; x[i] = X, y[i] = Y, r[i] = R; } Nx = x[N], Ny = y[N], Nr = (4-r[N]) % 4; for (i = 0; i < N; i++) { X = 0, Y = 0; rot(Px, Py, r[i]); pr(X+Nx-x[i], Y+Ny-y[i], Nr); } return 0; }