문제
There are teams participating in INC 2023. The team ranked in the th position is team , representing institution . It is known that the top teams in INC 2023 are eligible to participate in The ICPC Asia Jakarta 2023.
Apart from the top teams, Golden Tickets are given to at most top teams for which their institutions are not in the top of INC 2023. However, only at most one Golden Ticket will be given to each institution, and only the team with the highest rank in INC 2023 from each institution qualifies for the Golden Ticket. These Golden Tickets will allow them to participate in The ICPC Asia Jakarta 2023.
Determine the number of teams that will receive the Golden Tickets. Then, output the name of the teams that receive those Golden Tickets, sorted by the rank of the teams.
입력
The first line consists of three integers ().
Each of the next lines consists of two string () separated by a whitespace. All strings consist of upper case letters. There are no teams with the same name. Formally, for .
출력
The first line consists of an integer, representing the number of teams that will receive the Golden Tickets. Denote this number as .
Then, output lines, each consisting of the name of the teams that receive those Golden Tickets, sorted by their rank. If , then you do not need to print any names.
힌트
Disclaimer
All team names and institution names in the samples are fictional. Any similarities with actual participants in INC 2023 are purely coincidental.
예제 입력 1 복사
3 1 2
ARUA UOGX
NOIHS UHOLO
IKUBUF UHOLO
예제 입력 2 복사
3 2 1
ARUA UOGX
NOIHS UHOLO
IKUBUF UHOLO
예제 입력 3 복사
5 1 2
ARUA UOGX
NOIHS UHOLO
IKUBUF UHOLO
ANUZAN UVSH
LAMLA UNIJI
예제 입력 4 복사
9 3 3
ARUA UOGX
ANUZAN UVSH
NOIHS UHOLO
IKUBUF UHOLO
LAMLA UNIJI
IKASAS UNIJI
ESUOMNORI UVSH
AIHSUR URIP
AYNEH UVSH
예제 출력 1 복사
1
NOIHS
예제 출력 2 복사
0
예제 출력 3 복사
2
NOIHS
ANUZAN
예제 출력 4 복사
2
LAMLA
AIHSUR