cho.sh
Notes
Loading...

Asian Informatics Olympiad

Time limit

1s

Memory limit

128 MB

Problem

An online informatics olympiad is held for students from Asia. There is no limit on how many students may participate from each country.

The gold, silver, and bronze medalists are chosen by considering students in descending order of score. There are no tied scores. However, each country may receive at most two medals. If two students from a country have already received medals, another student from that country cannot receive the next medal even with a higher score.

Given the contest results, write a program that prints the gold, silver, and bronze medalists in order.

Input

The first line contains N, the number of participating students. 3 <= N <= 100.

Each of the next N lines contains one student's country number, student number, and score, separated by spaces. Country numbers are integers assigned in order starting from 1, and student numbers are integers assigned within each country starting from 1. Scores are integers from 0 to 1000, and no two students have the same score.

At least two countries appear in the input.

Output

Print the students who receive medals in the order gold, silver, and bronze, one student per line.

Each line must contain the medalist's country number and student number separated by one space.