Having mastered the secrets to the Art of Kinematics, you decide to show your power by challenging your physics teacher to a duel — a friendly one that is. The two of you are separated by a certain distance and right in the middle lies the holy book of SIN (more specifically, A Decade of SIN Plus Sixteen, which contains past contests and solutions to the University of Waterloo's Sir Isaac Newton Contest).

You believe you are worthy of bringing the book (which has a mass of 500.0g) home to solve problems from — but she wants you to suffer first. Using the force (yes, *that* force), she changes the velocity of the book several times. Since you are keeping your eyes on the clock, you know the exact time when she changes the velocity of the book and you also know the angle (as you always carry a protractor) and the duration of the time interval (you also have a stopwatch).

Your goal is to output the speed of the book when it hits the ground. Assume that the book is in free-fall on Earth after the last change in velocity is made and that it is accelerating towards the surface at . Assume that the book is unaffected by gravity while it is under the influence of the force.

#### Input Specification

The first line of input will contain one number that represents the number of changes.

The next lines will contain two integers and a real number, , and .

represents the speed of the book, in metres per second while represents the direction, in degrees. More specifically, is the angle between the book's direction and the east direction, clockwise.

represents the time, in seconds, that the book travelled for. Note that is given to one decimal place.

#### Output Specification

The only line of output is to contain the speed of the book when it hits the ground to the nearest integer.

#### Sample Input

```
2
10 30 2.0
5 120 1.5
```

#### Sample Output

`18`

#### Explanation for Sample Output

Our goal is to find the height the book reaches. Using the Law of Conservation of Energy we derive the following equation: , where is the height the book reached, is the acceleration due to gravity and represents the speed of the book when it lands on the ground (the desired output).

To obtain the height the book reached, we need to obtain the vertical component of the book's velocity in each of the lines.

Let represent the height that the book reaches.

Using ,

Note: The function in your language may require the input to be in radians rather than degrees. To convert from degrees (the input) to radians, simply multiply by .

## Comments