Robocode is an educational game designed to help learn Java. The players write programs that control tanks fighting with each other on a battlefield. The idea of this game may seem simple, but it takes a lot of effort to write a winning tank's program. Today we are not going to write an intelligent tank, but to design a simplified robocode game engine.
Assuming the whole battlefield is 120*120 (pixel). Each tank can ONLY move in vertical and horizontal direction on the fixed path (There are paths every 10 pixels in the battlefield in both vertical and horizontal direction. In all there are 13 vertical paths and 13 horizontal paths available for tanks, as shown in Figure 1). The shape and size of the tank are negligible and one tank has (x, y) (x, y ∈ [0, 120]) representing its coordinate position and α (α ∈ {0, 90, 180, 270}) representing its facing direction (α = 0, 90, 180 or 270 means facing right, up, left or down respectively). They have a constant speed of 10 pixels/second when they move and they can't move out of the boundary (they will stop moving, staying in the direction that they are currently facing, when touching any boundary of the battlefield). The tank can shoot in the direction it's facing whether it's moving or still. The shot moves at the constant speed 20 pixel/second and the size of the shot is also negligible. It will explode when it meets a tank on the path. It's possible for more than one shot to explode in the same place if they all reach a tank at the exact same time. The tank being hit by the explosion will be destroyed and will be removed from the battlefield at once. A shot exploding or flying out of the boundary will also be removed.
There are several test cases. The battlefield and paths are all the same for all test cases as shown in Figure 1. Each test case starts with integers N (1 <= N <= 10) and M (1 <= M <= 1000), separated by a blank. N represents the number of the tanks playing in the battlefield, and M represents the number of commands to control the tanks' moving. The following N lines give the initial information (at time 0) of each tank, in the format:
MOVE | When receiving the command, the tank starts to move in its facing direction. If the tank is already moving, the command takes no effect. |
STOP | When receiving the command, the tank stops moving. If the tank is already stopped, the command takes no effect. |
TURN angle | When receiving the command, the tank changes the facing direction α to be ((α + angle + 360) mod 360), no matter whether it is moving or not. You are guaranteed that ((α + angle + 360) mod 360) ∈ {0, 90, 180, 270}. TURN command doesn't affect the moving state of the tank. |
SHOOT | When receiving the command, the tank will shoot one shot in the direction it's facing. |
For each test case, output the winner's name in one line. The winner is defined as the last living tank. If there is no tank or more than one tank living at the end, output "NO WINNER!" in one line.
2 2 A 0 0 90 B 0 120 180 1 A MOVE 2 A SHOOT 2 2 A 0 0 90 B 0 120 270 1 A SHOOT 2 B SHOOT 2 6 A 0 0 90 B 0 120 0 1 A MOVE 2 A SHOOT 6 B MOVE 30 B STOP 30 B TURN 180 30 B SHOOT 0 0
A NO WINNER! B