Task
After you helped kids form teams for IKPC (International Kindergarten Programming Contest), you now want to know which team won the competition!
Your teacher provided you information regarding the number of teams, , the number of problems, , as well as the number of actions taken by the teams, .
For the action, you know the number of the team, , the problem number they submitted on, , as well as the verdict of the solution, if the solution was accepted or if the solution was rejected. If team did not submit a correct solution before the action to that problem , the penalty of the team corresponding to problem is increased by . If a team submits multiple solutions to a problem, the total penalty is increased by the sum of the penalties accumulated by the time the first correct solution was submitted, including the first correct solution. However, if a team never submits any correct solution to a problem , the penalties accumulated for are NOT added towards the final penalty.
For example, if a team submits the following solutions on problem , they will get the total penalty increased by , as only the submissions sent at times , and are considered. Take note that the wrong solution at time is not added to the total penalty.
- a wrong solution at time
- a wrong solution at time
- a correct solution at time
- a wrong solution at time
In order to simplify the competition, each action takes place at a different moment of time, thus the action will take place in the minute. The moments of time are indexed from .
The final standings of the competition are decided as follows:
- First, the teams are ordered in non-ascending order of the number of problems they solved. Warning, if the team submits more than a correct solution for the same problem, only the first correct solution is counted.
- If two or more teams are tied, they will be ordered in non-descending order of their penalties. Warning, in order to compute the penalty, we will consider the penalty accumulate only among the problems which weresolved, without considering the solutions sent after the problem was solved, irrespective of the status of the solution.
- If they are still tied, they will be ordered in the non-ascending order of the number of first solves they obtained. A first solve consists of a team being the first one to solve a certain problem.
- If they are still tied, they will be ordered in increasing order of their team numbers (if two teams have the exact same stats, the team with a smaller label goes first).
For example, if a team solved problems and has a penalty of , it will be ahead of any team who solved problems or less, as well as ahead any team who solved problems but with a penalty greater than or if they have the same penalty too, they will be ahead if they have more first solves than the other team or the same number of first solves too but a smaller label.
Input data
The first line of the input will contain the numbers , and , as stated above.
The next lines will each contain three values, , and , where () is the number of the team which had this action, () is the problem number they submitted on, is the verdict they got ( for rejected and for accepted).
Output data
The output will contain a single line, with the order of the teams, from the first placed team to the last placed team, according to the restrictions specified in the statement.
Constraints and clarifications
# | Points | Restrictions |
---|---|---|
1 | 30 | |
2 | 70 | No additional constraints. |
Example
stdin
7 11 17
5 3 0
4 11 1
2 5 1
3 9 1
2 11 1
7 7 0
6 1 1
4 2 1
6 11 1
4 9 1
5 5 0
1 4 1
2 2 1
2 6 0
6 10 1
3 8 1
3 5 1
stdout
4 2 6 3 1 5 7
Explanation
In the table below you can see the list of solved problems, penalty and first solves for each team.
Team | Solved problems | Penalty | First solve count |
---|---|---|---|
4 | 3 | 20 | 2 |
2 | 3 | 21 | 1 |
6 | 3 | 31 | 2 |
3 | 3 | 37 | 2 |
1 | 1 | 12 | 1 |
5 | 0 | 0 | 0 |
7 | 0 | 0 | 0 |