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:
The Name of a tank is consisted of no more than 10 letters. x, y, α are integers and x, y ∈ {0, 10, 20, ..., 120}, α ∈ {0, 90, 180, 270}。Each field is separated by a blank.
The following M lines give commands in such format:
Each field is separated by a blank. All the commands are giving in the ascending order of Time (0 <= Time <= 30), which is a positive integer meaning the timestamp when the commands are sent. Name points out which tank will receive the command. The Content has different types as follows:
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. |
Tanks take the corresponding action as soon as they receive the commands. E.g., if the tank at (0, 0), α = 90, receives the command MOVE at time 1, it will start to move at once and will reach (0, 1) at time 2. Notice that a tank could receive multiple commands in one second and take the action one by one. E.g., if the tank at (0, 0), α = 90, receives a command sequence of "TURN 90; SHOOT; TURN -90", it will turn to the direction α = 180, shoot a shot and then turn back. If the tank receives a command sequence of "MOVE; STOP", it will keep still in the original position.
Some more notes you need to pay attention:
- If a tank is hit by an explosion, it will take no action to all the commands received at that moment. Of course, all the commands sent to the already destroyed tank should also be omitted.
- Although the commands are sent at discrete seconds, the movement and explosions of tanks and shots happen in the continuous time domain.
- No two tanks will meet on the path guaranteed by the input data, so you don't need to consider about that situation.
- All the input contents will be legal for you.
A test case with N = M = 0 ends the input, and should not be processed.