Who made it through?#244

Who made it through?

1 second
256 megabytes
Easy

Many residents of Bitakulyandia take part in stages of international olympiads in informatics. In total, there are seven such olympiads held in Bitakulyandia:

  1. IOI - International Olympiad in Informatics

  2. CEOI - Central-Eventora Olympiad in Informatics

  3. EGOI - Eventora Girls Olympiad in Informatics

  4. EJOI - Eventora Junior Olympiad in Informatics

  5. BaltOI - Balticodian Olympiad in Informatics

  6. BalkOI - Balkolian Olympiad in Informatics

  7. JBOI - Junior Balkolian Olympiad in Informatics

Miss M organizes olympiads of various stages, as well as selection (selection-training) camps for all seven international olympiads. After the last round of selection is held, teams of four to six people are formed for all seven olympiads. But only those participants who meet the participation criteria for the olympiad should be sent to each competition. Here is the list of algorithms for determining the members of the team for the olympiads:

  1. IOI - The best participants based on the total scores from all selection rounds.

  2. CEOI - The best participants based on the total scores from all selection rounds.

  3. EGOI - The best participants based on the total scores from all selection rounds, who are girls.

  4. EJOI - The best participants based on the total scores from all selection rounds, who are no older than years.

  5. BaltOI - The best participants based on the total scores from all selection rounds.

  6. BalkOI - The best participants based on the total scores from all selection rounds, who are not th-graders.

  7. JBOI - The best participants based on the total scores from all selection rounds, who are not th- or th-graders.

If there are fewer participants than the required number, this means that the team will consist of a smaller number of people. For example, if it is necessary to determine the team for EGOI, and there are only two girls, this means that the team will consist of only two participants, not four.

Since there are many participants in the olympiads, and there are many olympiads themselves, and the results are needed instantly after the competitions end, Miss M asks you to write a program that, based on the results and information about the participants, gives the composition of the teams of participants for the international olympiads.

Input

The first line contains an integer (1 \leq n \leq 10^{4}) — the number of participants in the olympiad.

Each of the following lines contains information about the olympiad participants:

  • — the unique number of the participant (10^6 \leq id < 10^7);

  • — the gender of the participant (male — male, female — female);

  • — the grade level of the participant (1 \leq grade \leq 11);

  • — the age of the participant (10 \leq age \leq 20);

  • — the number of points scored by the participant across all selection rounds (0 \leq score \leq 10^8).

It is guaranteed that all 's and 's of the participants are distinct.

The next line contains an integer (1 \leq m \leq 7) — the number of international olympiads for which Miss M wants to know the composition of the teams of participants.

The next lines contain the names of the international olympiads for which the composition of the teams of participants must be output. Possible olympiads: IOI, CEOI, EGOI, EJOI, BaltOI, BalkOI, JBOI. It is guaranteed that all olympiads are distinct.

Output

Output lines, which contain the names of the international olympiads, in the same order as specified in the input data, and the 's of the participants who are included in the teams, in the format of increasing order of the participant's number.

Examples

Example

Loading
Loading

Note

All participants can take part in IOI, the results table will look as follows:

  1. — points

  2. — points

  3. — points

  4. — points

  5. — points

  6. — points

  7. — points

  8. — points

  9. — points

  10. — points

The olympiad team consists of , , , .

Only girls can take part in EGOI, the results table will look as follows:

  1. — points

  2. — points

  3. — points

The olympiad team consists of , , .

All participants can take part in BaltOI, the results table will look the same as for IOI. The same participants will make it into the team as for IOI, but also and .

Scoring

In this problem there are tests in which m=1 for each possible olympiad. That is, if you can solve the problem only for a certain olympiad, you are guaranteed to receive points.