import std.conv, std.functional, std.range, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; } int readInt() { return readToken.to!int; } long readLong() { return readToken.to!long; } real readReal() { return readToken.to!real; } bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } } bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } } int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; } int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); } int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); } enum SZ = 3; long[][] mul(long[][] a, long[][] b) { auto c = new long[][](SZ, SZ); foreach (i; 0 .. SZ) foreach (k; 0 .. SZ) foreach (j; 0 .. SZ) { c[i][j] += a[i][k] * b[k][j]; } return c; } int N; long PX, PY; int[] T; long[] D; void main() { try { for (; ; ) { N = readInt(); PX = readLong(); PY = readLong(); T = new int[N]; D = new long[N]; foreach (i; 0 .. N) { T[i] = readInt(); if (T[i] == 1 || T[i] == 2) { D[i] = readLong(); } } auto as = new long[][][](N, SZ, SZ); foreach (i; 0 .. N) { switch (T[i]) { case 1: { as[i][0][0] = 1; as[i][1][1] = 1; as[i][2][2] = 1; as[i][0][2] = D[i]; } break; case 2: { as[i][0][0] = 1; as[i][1][1] = 1; as[i][2][2] = 1; as[i][1][2] = D[i]; } break; case 3: { as[i][0][1] = 1; as[i][1][0] = -1; as[i][2][2] = 1; } break; default: assert(false); } } auto asProd = new long[][][N + 1]; asProd[N] = new long[][](SZ, SZ); asProd[N][0][0] = 1; asProd[N][1][1] = 1; asProd[N][2][2] = 1; foreach_reverse (i; 0 .. N) { asProd[i] = mul(asProd[i + 1], as[i]); } foreach (i; 0 .. N) { const ansX = asProd[i][0][0] * PX + asProd[i][0][1] * PY + asProd[i][0][2]; const ansY = asProd[i][1][0] * PX + asProd[i][1][1] * PY + asProd[i][1][2]; writeln(ansX, " ", ansY); } } } catch (EOFException e) { } }