12414 - Midorimushi   

Description

Hey, do you want to hear something amazing?  I saw a Paramecium moving 10 millimeters per second!

The Paramecium is at (0,0) and facing north initially (where north refers to positive direction of y-axis, east refers to positive direction of x-axis). The movement of Paramecium is observed and recorded as the following format :

 t_1 action_1
 t_2 action_2
 ...
 t_n action_n

The i-th of the record means that in the t_i-th second, the Paramecium did action_i. Actions by be either "right-turn"(recorded as 0), "left-turn"(recorded as 1), or "stop"(recored as 2).

For example (Sample I/O) :

  • Initially, Paramecium is at (0,0), facing north.

  • At 7-th second, Paramecium made a right-turn. At this moment it is at (0, 70), facing east.

  • At 12-th second, Paramecium made a left-turn. At this moment it is at (50, 70), facing north.

  • At 29-th second, Paramecium made a left-turn. At this moment it is at (50, 240), facing west.

  • At 487-th second, Paramecium stopped. At this moment it is at (-4530, 240), facing west.

Given the record, please output the coordinate when the Paramecium stopped.

Input

Input contains multiple lines. Each line has two integer: timestamp t (in seconds) and action a.

It is guaranteed that ...

  1. 0 <= t < 100000000

  2. a=0 or 1 or 2. a=0 means that the action is a right-turn. a=1 means that the action is a left-turn. a=2 mean that the action is stop.

  3. The last line is always a=2 (action = stop) and a=2 will only appear in the last line.

Output

Output two integer x, y, separated with a space between them, with a new line character in the end.

Meaning that the Paramecium stopped in (x,y) finally.

Sample Input  Download

Sample Output  Download

Tags




Discuss