GeoGame
Alimzhan play interesting games a lot. One of them is GeoGame. In this game you stay at the plane, and your position can be described as point (x, y) in the plane. There are enemies with special powers: mages, warriors and tricksters. Their aim to confuse Alimzhan about his position, so that he won't know where he is. Each of them can affect Alimzhan's position in some way:
x y - warrior knocks and pushes by x towards OX axis, and by y towards OY axis.
a b - mage in point (0, 0) rotate you around his position on a * π / b radians counterclockwise.
b x y - trickster sends you in mirror world: he creates infinite mirror (some line), so that Alimzhan turns into his mirror image.
There are n actions your enemies can possibly do: A[1]
, A[2]
, ..., A[n]
. Alimzhan tired of games, so he asks your to answer q queries: what is his new position after consequent effects A[l]
, ..., A[r]
(in this order), if his starting position is (x, y)?
Input
In the first line you are given n (1 ≤ n ≤ 3 * 10^5
). In the next n lines you are given n actions - each action starts with t - type of operations:
1 x y - warrior's action (|x| ≤ 100, |y| ≤ 100)
2 a b - mage's action (|a| ≤ b ≤ 42)
3 b x y - trickster's action - mirror (line) is defined with 2 points (b, 0) and (x, y) (|b|, |x|, |y| ≤ 100).
In the (n + 1)-th line you are given number of queries q (1 ≤ q ≤ 3 * 10^5
).
In the new q lines you are given queries. Each query is 4 integers in format l r x y (1 ≤ l ≤ r ≤ n).
Output
For each of q queries output the final position as two real numbers. Your answer is considered correct ifyour absolute or relative error don't exceed 10^(-4)
.