ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

2112. Battle log

Time limit: 1.0 second
Memory limit: 256 MB
Not so long ago a qualification round for the world tournament in popular game PKBG took place. In order to determine the participants who passed qualification round, organizers asked them to provide a log of a qualification battle.
There are multiple teams in the battle. Each team has exactly 4 members. The total number of participants is n (it is guaranteed that n is divisible by 4). For the sake of anonymity, the identities of members of the teams are not disclosed. There are in total 3 different types of events in the logs:
  • X HIT Y IN BODY/HEAD — player X hit player Y in the body/head;
  • X USES MEDKIT — player X uses a medical kit and gets fully healed;
  • X REVIVE Y — player X revives player Y.
Every player has 4 conditions: “healthy”, “injured”, “at death’s door” and “dead”. Let’s numerate the condition of players from 3 to 0 in the same order they were described before. When hit in the body or the head, the condition of a player changes to max(0, cur − 1) and max(0, cur − 2) correspondingly, where cur is the current condition of a player. Using a medical kit makes player healthy. Revival changes player’s condition from “at death’s door” to “injured”. In the beginning all the players are healthy. You may assume that no player ever runs out of ammunition or medical kits.
There are also some strict rules in the game:
  • Only healthy or injured player can hit other players, use medical kit and revive other players;
  • Players can only revive their teammates who are in the condition “at death’s door”;
  • Every player is part of a team containing 4 players in total.
If any rule was violated, logs are considered fake. Any events not restricted by the rules are possible. For example, a player may accidentally hit his teammate or even himself.
There is not much time before the start of the world tournament. You, as a lead software engineer, have to verify the correctness of the logs and predict possible teams. If there are several ways to compose teams in a correct way, you may output any of them.

Input

The first line contains a single integer n (4 ≤ n ≤ 1000) — the total number of players. Each of the next n lines contains a name of a player. Each name is a string, containing lowercase and uppercase English letters. Length of each name does not exceed 20. All the names are different. The next line contains a single integer m (0 ≤ m ≤ 104) — the number of events in the battle log. The next m lines contain event descriptions in the format defined before. It is guaranteed that the event descriptions strictly follow the format.

Output

Output “FAKE” (without quotes), if logs are fake, otherwise output “CORRECT” (without quotes), and in the next n / 4 lines output any possible way to compose teams, 4 names in each line. Names in the same line should be separated with a space.

Samples

inputoutput
8
Shroud
Forsen
Wycc
Ragyra
BeastQT
Lirik
Asmadey
Ninja
12
Wycc HIT Shroud IN BODY
Shroud HIT Wycc IN HEAD
Ragyra REVIVE Wycc
Wycc USES MEDKIT
Lirik HIT BeastQT IN BODY
Asmadey HIT BeastQT IN BODY
Asmadey REVIVE BeastQT
Ragyra HIT Forsen IN HEAD
Shroud REVIVE Forsen
BeastQT HIT Shroud IN HEAD
Wycc HIT Forsen IN HEAD
Ninja HIT BeastQT IN HEAD
CORRECT
Wycc Ragyra BeastQT Asmadey
Lirik Ninja Shroud Forsen
8
Shroud
Forsen
Wycc
Ragyra
BeastQT
Lirik
Asmadey
Ninja
8
Shroud HIT Wycc IN HEAD
Shroud HIT Ragyra IN HEAD
Shroud HIT BeastQT IN HEAD
Shroud HIT Asmadey IN HEAD
Lirik REVIVE Wycc
Lirik REVIVE Ragyra
Lirik REVIVE BeastQT
Lirik REVIVE Asmadey
FAKE
4
Shroud
Forsen
Wycc
Ragyra
3
Shroud HIT Wycc IN HEAD
Wycc HIT Shroud IN HEAD
Wycc HIT Shroud IN BODY
FAKE
Problem Author: Ivan Sychev
Problem Source: University academic school olympiad in informatics 2019