Training Site

Spaceships

Input: Standard Input (stdin)
Output: Standard Output (stdout)
Memory limit: 64 megabytes
Time limit: 3.0 seconds

You have landed a great internship with the corporation Galactic Flight Controllers. You are given a relatively simple task: to determine appropriate flight paths for two spaceships in orbit around a planet. The mission objective is to catch a mysterious orbiting object.

For the object to be caught, it must be in between the two spaceships' net launchers. More specifically, Alpha will launch a net that B will catch. The missile must be in between the spaceships to be caught.

If the missile is at the same position as one of the spaceships, they will catch the missile with a smaller net that does not need to be launched.

You will be given a series of moves that the spaceships will carry out, and from this determine if it is possible to catch the object. All measurements are given in degrees around the planet.

Spaceship Alpha and Beta start at 0 and 90 degrees respectively. They can then do two moves:

• BOOST - Moves Beta forwards by a certain angle.
• TRAVEL - Moves Alpha and Beta by a certain angle (synchronously).

Input

• A number of lines in the format ORDER ANGLE. For example, BOOST 90 means a boost of 90 degrees.
• The last line of orders will be END 0.
• Then, the location (in degrees) of the object is given as an integer on another line.

Output

Output two space-separated integers with Alpha and Beta's coordinates in degrees respectively. On a second line, either Missile located. or Missile unlocatable.

• 25%: only TRAVEL commands will be given, and the spaceships will not travel past 360 degrees.
• 25%: only TRAVEL commands will be given.
• 50%: no further restrictions.

There will be at most 100 lines of input.

• Sample Input 1

BOOST 50
TRAVEL 100
END 0
30


Sample Output 1

100 240
Missile unlocatable.