Who Advanced?
Many residents of Bitaculandia participate in the stages of international programming olympiads. There are seven such olympiads held in Bitaculandia:
IOI
- International Olympiad in InformaticsCEOI
- Central-Eventora Olympiad in InformaticsEGOI
- Eventora Girls Olympiad in InformaticsEJOI
- Eventora Junior Olympiad in InformaticsBaltOI
- Balticodian Olympiad in InformaticsBalkOI
- Balkolian Olympiad in InformaticsJBOI
- Junior Balkolian Olympiad in Informatics
Miss M is responsible for organizing various stages of olympiads, as well as selections (training camps) for all seven international stages. After the last selection round, teams of four to six people are formed for all seven olympiads. However, only those participants who meet the criteria for participation in the olympiad should be sent to each competition. Here is a list of algorithms for determining the participants of the teams for the olympiads:
IOI
- Top participants based on the total scores from all selection rounds.CEOI
- Top participants based on the total scores from all selection rounds.EGOI
- Top female participants based on the total scores from all selection rounds.EJOI
- Top participants at most years old based on the total scores from all selection rounds.BaltOI
- Top participants based on the total scores from all selection rounds.BalkOI
- Top participants who are not in th grade based on the total scores from all selection rounds.JBOI
- Top participants who are not in th or th grade based on the total scores from all selection rounds.
If there are fewer participants than the required number, it means that the team will consist of fewer people. For example, if you need to determine the team for EGOI
and there are only two girls, it means that the team will consist of only two participants, not four.
Since there are many participants and many olympiads, and the results are desired immediately after the competition ends, Miss M asks to write a program that, based on the results and information about the participants, provides the composition of the teams for the international stages of the olympiads.
Input
The first line contains an integer () — the number of olympiad participants.
Each of the following lines contains information about the olympiad participants:
— unique participant number ();
— participant's gender (
male
— male,female
— female);— participant's grade level ();
— participant's age ();
— the number of points participants have from all selection rounds ().
It is guaranteed that all and of participants are different.
The next line contains an integer () — the number of international olympiads for which Miss M wants to know the composition of the participant teams.
The following lines contain the names of the international olympiads for which the composition of the participant teams needs to be output. Possible olympiads: IOI
, CEOI
, EGOI
, EJOI
, BaltOI
, BalkOI
, JBOI
. It is guaranteed that all olympiads are different.
Output
Output lines, containing the names of the international olympiads, in the same order as specified in the input data, and the of participants who are part of the teams, in the format of increasing participant number.
Examples
Note
All participants can take part in IOI
, the results table will look like this:
— points
— points
— points
— points
— points
— points
— points
— points
— points
— points
The participants who will go to the olympiad are , , , .
Only girls can participate in EGOI
, the results table will look like this:
— points
— points
— points
The participants who will go to the olympiad are , , .
All participants can take part in BaltOI
, the results table will look the same as for IOI
. The same participants who will go to IOI
will also go to BaltOI
, as well as and .
Scoring
In this problem, there are tests where for each possible olympiad. That is, if you can only solve the problem for a certain olympiad, you are guaranteed to receive points.