comori

Finding a treasure hidden by pirates is easy if you have a map. Usually the map comes with an algorithm that describes moving towards the treasure. E.g.: "Find the white rock. Go 30 steps towards the forest, then 15 towards the lake, ... , and 20 through the cave. The treasure is buried under the mark on the right wall".
Usually one indication involves moving a certain number of steps in one of the given directions (1 - north, 2 - north-east, 3 - east, 4 - south-east, 5 - south, 6 - south-west, 7 - west, 8 - north-west). One step always takes you from a point with integer coordinates to another point with integer coordinates. So, if at some moment you are in the point having the integer coordinates (X, Y), moving 1 step in one of the 8 directions will take you in the following point also having integer coordinates:

Direction
Where to
1
(X, Y+1)
2
(X+1, Y+1)
3
(X+1, Y)
4
(X+1, Y-1)
5
(X, Y-1)
6
(X-1, Y-1)
7
(X-1, Y)
8
(X-1, Y+1)


Thus, the journey via the described route becomes simple. For example, in the picture you go 3 steps north, 1 east, 1 north, 3 east, 2 south and 1 step west.


Task

Write a program that, following the pirates' indications, determines the point where the treasure is hidden. The axis Ox is oriented east and the axis Oy is oriented north. Initially, the treasure seeker is in the origin of the coordinate system (point with coordinates (0, 0)).

Input data

The first line of input file comori.in contains a natural number N, representing the number of indications given. The following N lines contain the so-called indications, one indication per line. One indication is given as two positive integers numbers separated by a space, d p, where d represents the number of the direction, and p the number of steps.

Output data

Output file comori.out will contain a single line with two integers separated by a space, x y, representing the x-coordinate, and respectively the y-coordinate of the point where the treasure is hidden.

Constraints and clarifications

Example
comori.in comori.out comori.in comori.out
6
1 3
3 1
1 1
3 3
5 2
7 1

3 2

1
8 10

-10 10

Time limit: 0.1 seconds/test

prof. Sergiu Corlat
Chişinău Moldavian-Turkish High-School
Contact: scorlat@gmail.com