lib C fun strtoll(s : UInt8*, p : UInt8**, b : Int32) : Int64 end class String def to_i64 C.strtoll(self, nil, 10) end end n, px, py = read_line.split.map(&.to_i64) com = (1..n).map { read_line.split.map(&.to_i64) } x1, x2, y1, y2, s = 1i64, 0i64, 1i64, 0i64, false ans = com.reverse.map do |a| case a[0] when 1 x2 -= a[1] when 2 y2 -= a[1] when 3 y1 *= -1 x1, y1 = y1, x1 x2, y2 = y2, x2 s = !s end x, y = px, py x = (x - x2) * x1 y = (y - y2) * y1 x, y = y, x if s {x, y} end puts ans.reverse.join('\n', &.join(' '))