N, Px, Py = map(int, input().split()) C = [tuple(map(int, input().split())) for _ in range(N)] res = [] cur = complex(Px, Py) orient = 1 for c in reversed(C): if c[0] == 1: cur += c[1] * orient elif c[0] == 2: cur += c[1] * 1j * orient else: cur *= -1j orient *= -1j res.append((cur.real, cur.imag)) for xy in reversed(res): print(*map(round, xy))