Recently, Keenan has been thinking about some very interesting questions. Unfortunately, searching them on the internet hasn't been very useful. Instead, Keenan has started to direct his inquiries to various university professors by email. Keenan has received so many responses that he needs to start keeping track of what questions he has asked from each professor, as well as rate the quality of their responses.
Keenan has questions and has emailed professors so far. Each professor has responded to all of the questions that Keenan has asked, and Keenan has assigned each answer a certain score. Keenan has given you a list of emails that he has sent as well as his score for each of the responses. To make it easier to create the ratings, all values, including the identity of the professor are recorded with positive integers.
Can you help him find the identity of the professor who responded the best to each question?
Constraints
Subtask 1 [30%]
Subtask 2 [70%]
No additional constraints.
Input Specification
The first line of input will contain 3 space separated integers, , , . represents the number of questions Keenan has, represents the number of professors he knows and represents the number of emails Keenan has sent.
The next lines will each consist of 3 space separated integers: , , . represents the professor that Keenan emailed, represents the question that Keenan asked and represents the score Keenan gave the answer.
Output Specification
The output will consist of space separated integers, the th integer should represent the identity of the professor that best answered the th problem. If no professor answered a problem, output -1
instead. If two professors had the same score answer, output the one that answered first (the one that appeared earlier in the input).
Sample Input
5 5 4
1 3 4
2 3 9
1 4 1
5 1 10
Sample Output
5 -1 2 1 -1
Explanation
Keenan asked professor for the answer to question , which was professor . Keenan gave this answer a score of . This is the best (and only) score, so professor answered best for question .
Keenan didn't ask any professor about question .
Keenan asked professors about question . Professor gave an answer that was rated and Professor gave an answer that was rated . Professor had the highest score, so he answered best.
Keenan asked professor about question , Professor gave the one and only answer with a rating of . Therefore, professor gave the best answer.
Keenan didn't ask any professor about question .
Comments