n, px, py = gets.split.map(&:to_i) x1, x2, y1, y2, s = 1, 0, 1, 0, false puts (1..n).map { gets.split.map(&:to_i) }.reverse.map { |a| case a[0] when 1 x2 -= a[1] when 2 y2 -= a[1] when 3 x1, x2, y1, y2, s = -y1, -y2, x1, x2, !s end x, y = (px - x2) * x1, (py - y2) * y1 x, y = y, x if s [x, y] }.reverse.map { _1.join(' ') }.join("\n")