GeoGame#9412

GeoGame

2 seconds
256 megabytes
Easy

Alimzhan plays 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 (, ) in the plane. There are enemies with special powers: mages, warriors and tricksters. Their aim is 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:

1. - warrior pushes you by along the axis, and by along the axis.

2. - mage in point (, ) rotate you around his position on a \cdot \pi / b radians counterclockwise.

3. - trickster sends you in mirror world: he creates infinite mirror (some line), so that Alimzhan turns into his mirror image.

There are actions your enemies can possibly do: A_1, A_2, \ldots, A_n. Alimzhan is tired of games, so he asks you to answer queries: what is his new position after consecutive effects A_l, \ldots, A_r (in this order), if his starting position is (, )?

Input

In the first line you are given (1 \le n \le 3 \cdot 10^5). In the next lines you are given actions - each action starts with - type of operations:

- warrior's action (|x| \le 100, |y| \le 100)

- mage's action (|a| \le b \le 42)

- trickster's action - mirror (line) is defined with points (, ) and (, ) (|b|, |x|, |y| \le 100).

In the (n + 1)-th line you are given number of queries (1 \le q \le 3 \cdot 10^5).

In the next lines you are given queries. Each query is integers in format (1 \le l \le r \le n).

Output

For each of queries output the final position as two real numbers. Your answer is considered correct if your absolute or relative error don't exceed 10^{-4}.

Examples

Example 1

Loading
Loading