Everybody knows that men in black protect our Earth from alien cockroaches and other vermin. They track all movements of our alien foes and friends and control their actions. But recently, the government has learned about men in black and decided to track all their movements.
There are several agents. Each agent has several characteristics: accuracy, intelligence, walking speed, experience, and driving skill. All characteristics are real numbers ranging from to . Also, each agent has a code letter from to , since his name is top secret. When a new agent joins the organization, he is assigned the letter closest to the first letter of his name that is not assigned to any agent. If there are several such letters, the one which comes first lexicographically is chosen. For example, if there are already agents , , and in the organization, and an agent named Killer joins, he gets the letter .
Men in black have several cars that agents use in their work. The speed of an agent when driving is equal to his driving skill. However, some cars require the agent to have a driving skill greater than or equal to a predefined value. Each car has a maximum distance it can travel before becoming unusable.
There are several kinds of alien monsters in the universe that men in black fight. An agent can kill a monster if his experience and intelligence are greater than or equal to some predefined values for this kind of monster. Each kind of monster has an evasiveness value, and depending on the agent's accuracy, it can take different amounts of time to kill a monster. A killed monster gives the agent who killed it some experience.
There are four types of quests that men in black perform:
1. **Delivery quest** — Get from the office to the destination point and back. For such quests, the distance from the office to the destination point is given. 2. **Kill the monster quest** — Get to the monster, kill it, and get back. For such a quest, you are given the distance to the monster and its kind. The time that an agent with accuracy needs to kill a monster with evasiveness is equal to . The agent receives (1-x) \cdot m / \max x experience, where is the agent's experience, is the experience value associated with this kind of monster, and is the maximal possible experience. The agent's accuracy increases by (1-a) \cdot e / \max e where is the maximal possible evasiveness of monsters. 3. **Investigation quest** — Get to the point where the investigation is needed, perform it, get back. For such a quest, you are given the distance to the investigation point and the minimal intelligence required. The time needed to perform the investigation by an agent with intelligence is , where is the minimal required time for the investigation. After completing the investigation, the agent receives (1-x) \cdot i / \min t experience (where is the agent's experience before the operation). His intelligence increases by (1-i) \cdot i / \min t. 4. **Negotiations quest** — Get to the point of negotiations, discuss, and get back. You are given the distance from the office to the negotiations point and the minimal experience required. The time needed for an agent with experience to complete the discussion is , where is the minimal required time. After negotiations, the agent receives (1-x) \cdot x / \min t additional experience.
Each quest can be performed by one or two agents. If two agents perform the same quest, after it their characteristics change as if each of them completed the quest alone. An agent can walk to the quest location or drive there. If the car breaks while the agent is driving, he must continue on foot for the remainder of the journey. If the quest is performed by two agents, they can use the same car to get there.
The following algorithm is used to choose an agent or a pair of agents to perform a quest:
- The agent (or pair) who would complete the quest in the shortest time is chosen. - If several possibilities exist: 1. One agent is preferred over a pair of agents. 2. Among agents, the one with the smallest letter is chosen; for pairs, the ordered pairs of letters are compared. 3. Agents always choose a car that allows them to perform the quest in the shortest time. If the time is the same without a car, the car is not used. 4. If several cars provide the same quest time, the car with the lexicographically smallest ID is chosen.
All quests are performed as soon as they can be. If multiple quests are available, the one that was received first is performed first.
After the agent completes a quest where he had to walk, his walking speed increases by (1-s) \cdot d / \max d, where is his walking speed before the quest, is the distance he walked, and is the maximal possible walking distance. If the agent was driving for any distance, his driving skill increases by (1-z) \cdot d / \max d, where is the agent's driving skill before the quest, and is the distance driven.
For pairs, the following rules are used when performing a quest: - Walking speed: minimum of the agents' walking speeds. - Driving skill: maximum of the agents' driving skills. - Accuracy: (a_1 + a_2)/2. - Experience: 1 - (1-e_1)(1-e_2). - Intelligence: 1 - (1-i_1)(1-i_2).
The following events can happen: receiving a new quest, arrival of a new agent, purchase of a new car.
If an agent's experience becomes greater than or equal to the retirement experience, the agent leaves the organization immediately after completing his last quest. His letter becomes free and can be assigned to a new agent. There are never more than agents in the agency at any time.
All time intervals in this problem are in minutes and rounded to the nearest minute (standard rules). For example, the driving, walking (when a car breaks), and killing a monster intervals must be rounded independently.
All numbers and words in the input are separated by spaces and/or newlines.
The input contains:
- The number of agents (), followed by the description of each agent. Each agent is described by his name, accuracy, walking speed, intelligence, experience, driving skill, and assigned letter. All letters are different. The experience of every agent is less than the retirement experience. - The number of car types (). For each car type: the minimal required driving skill, the maximal distance before breaking, the type's name. - The number of cars (). For each car: its type, current distance passed (not exceeding the maximum), its ID. - The number of monster kinds (). For each: minimal experience needed, minimal intelligence needed, evasiveness, experience value for killing, and the monster's name. - Maximal possible walking distance, maximal monsters' evasiveness, maximal experience for monster killing, retirement experience. - The number of events in the organization (). For each event: the time it occurs, then: - New agent: 'newagent', agent's name, accuracy, walking speed, intelligence, experience, and driving skill. - New car: 'newcar', car type, current distance, ID. - Delivery quest: 'quest run', distance. - Kill quest: 'quest kill', distance, monster type. - Investigation: 'quest findout', distance, minimal intelligence, minimal investigation time. - Negotiations: 'quest talk', distance, minimal experience, minimal negotiation time.
All characteristics are floating point numbers between and (not inclusive), with no more than digits after the decimal. All other numbers are positive integers \leq 10^6. All agent names, car type names, monster names, and car IDs consist only of English letters and digits, of length . All names and IDs are unique. All events are sorted by time; all times differ.
Output all interesting events in the format: 'dddd:hh:mm <description>', where 'dddd:hh:mm' are the day, hour, and minute when the event occurs.
The following moments are interesting (in this order):
- **"MIB bought a car of class <name>."** - **"Car <id> was broken."** - **"Agent <A>[ and agent <B>] killed monster <monster>."** - **"Agent <A>[ and agent <B>] finished quest <number>."** - **"Agent <A> has tired."** - **"New agent <name> got a letter <letter>."** - **"Agent <A>[ and agent <B>] started quest <number>[ using car <id>]."**
All quests are numbered starting from in the order received. If several interesting events occur simultaneously, list them in the order above. If several events of the same type occur at the same time, list them in lex order. If two agents perform a quest, list them in the order of their code letters.
It is guaranteed that all quests can be completed before day from the beginning.
Example 1