# 2019 Fall KBTU OPEN

# 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`

. Alimzhan tired of games, so he asks your to answer _{n}**q** queries: what is his new position after consequent effects `A`

, ..., _{l}`A`

(in this order), if his starting position is (_{r}**x**, **y**)?

#### Input

In the first line you are given **n** (**1** ≤ **n** ≤ **3** * `10`

). In the next ^{5}**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 if
your absolute or relative error don't exceed `10`

.^{-4}

3 1 -1 2 2 1 2 3 -1 -3 2 3 1 1 5 0 1 2 5 0 1 3 5 0

4.000000 2.000000 -2.000000 4.000000 -5.000000 1.000000