Treasure#751

Treasure

1 second
64 megabytes
Very easy

Finding the treasure buried by pirates is simple: all you need is a map. Pirates usually hand-draw maps and describe the treasure-finding process like this: "Stand by the lone palm tree. Walk thirty steps towards the forest, then seventeen steps towards the lake, ..., finally ten steps towards the large rock. The treasure is buried beneath it." Most of these instructions require taking a certain number of steps in one of eight directions ( – north, – northeast, – east, – southeast, – south, – southwest, – west, – northwest) (see figure). Each step in any direction has a length of .

While following such a path is a great way to explore the area, in today's world nobody has time for that. Therefore, treasure hunters prefer to go directly to the point where the treasure is buried. For example, instead of taking three steps north, one step east, one step north, three steps east, two steps south, and one step west, you can go directly, taking approximately steps (see figure).

Your task is to write a program that, based on the pirates' instructions, determines the coordinates of the point where the treasure is buried.

Input

The first line of the input contains the number (1 \leq N \leq 40) – the number of instructions. The following lines contain the instructions: the direction number (an integer from to ) and the number of steps (an integer from to ). The numbers are separated by spaces.

Output

Print the coordinates and of the point (two real numbers separated by a space) where the treasure is buried, assuming the axis points east and the axis points north. The treasure hunter starts at the origin. Print the coordinates with a precision of 10^{-3}.

Examples

Example 1

Loading
Loading