There is a big argument between Stofl and his mice colleagues about a particular cheesy piece of cheese they found. They don’t find another way but to play a game of tank war to determine who will receive the cheese.
Tank War is played on a straight line of a particular length and there are up to 8 players playing against each other. Each player occupies a position on the line and has different weapons and a number of moving points.
A battle is played in turns. In each turn all the players act simultaneously according to the following scheme:
Note that the line can be interpreted as connected at the ends. That is, you can move from the left boundary leftwards and you appear at the right end. If you fire a missile over the boundary, it enters the line again on the other side.
The different weapons are specified by three parameters:
For every weapon, you have an unlimited number of missiles to fire. If you choose to change your weapon, it costs you one moving point.
At the beginning of a battle, you get information about the world and the different weapons from the standard input. First, you read three integers L, P, W, where L is the length of the world, P is the maximal damage one can have before leaving the game and W is the number of weapons you have. W lines follow, each of which contains the description of a weapon by three integers: its range, impact radius and damage points. The weapons are numbered from 1 to W.
Prior to every turn you have to read information about the game state from the standard input. The first line contains a single integer N, the number of players remaining in the battle. The second line contains three integers: your position, moving points and damage points (0 at the beginning of the battle). The next 2 (N-1) lines contain the same information about all the other players still in the game. The description of the i-th player consists of two lines:
The first of these contains the name of that player (no more than 20 lower-case letters). The second line contains three integers: his position, moving points and damage points (0 at the beginning of the game).
After reading the input you have to output your move by three integers (see remarks):
Note: If your move is illegal or your program does not respond as it should, your player will stay at his position and not fire a missile in that turn.
Your program can safely exit as soon as N is smaller than 2.
For every weapon:
0 ≤ moving points of the players at beginning ≤ 10 000