Treasure
Finding the treasure buried by pirates is straightforward: all you need is a map. Pirates typically hand-draw maps and describe the treasure-finding algorithm 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 involve taking a certain number of steps in one of eight directions (1 – north, 2 – northeast, 3 – east, 4 – southeast, 5 – south, 6 – southwest, 7 – west, 8 – northwest) (see figure). Each step in any direction is equal to 1 unit.
While following such a path is a great way to explore the area, in today's fast-paced world, no one has time for that. Therefore, treasure hunters prefer to go directly to the treasure's location. For instance, 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 3.6 steps (see figure).
Your task is to write a program that determines the coordinates of the treasure based on the pirates' instructions.
Input
The first line of the input contains the number N – the number of instructions (1 ≤ N ≤ 40). The following N lines contain the instructions – each line has a direction number (an integer from 1 to 8) and the number of steps (an integer from 1 to 1000). The numbers are separated by spaces.
Output
In the output, print the coordinates X and Y of the point (two real numbers separated by a space) where the treasure is buried, assuming the Ox axis points east and the Oy axis points north. Initially, the treasure hunter starts at the origin. The coordinates must be printed with a precision of 10^{-3}.