## 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, $N$, the number of problems, $P$, as well as the number of actions taken by the teams, $Q$.

For the $i^{th}$ action, you know the number of the team, $t_i$, the problem number they submitted on, $p_i$, as well as the verdict of the solution, $1$ if the solution was accepted or $0$ if the solution was rejected. If team $t_i$ **did not submit** a correct solution before the $i^{th}$ action to that problem $p_i$, the penalty of the team corresponding to problem $p_i$ is increased by $i$. 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 $p$, the penalties accumulated for $p$ are **NOT** added towards the final penalty.

For example, if a team submits the following solutions on problem $1$, they will get the total penalty increased by $24$, as only the submissions sent at times $5$, $9$ and $10$ are considered. Take note that the wrong solution at time $15$ is not added to the total penalty.

- a wrong solution at time $5$
- a wrong solution at time $9$
- a correct solution at time $10$
- a wrong solution at time $15$

In order to *simplify* the competition, each action takes place at a different moment of time, thus the $i^{th}$ action will take place in the $i^{th}$ minute. The moments of time are indexed from $1$.

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 $10$ problems and has a penalty of $190$, it will be ahead of any team who solved $9$ problems or less, as well as ahead any team who solved $10$ problems but with a penalty greater than $190$ 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 $N$, $P$ and $Q$, as stated above.

The next $Q$ lines will each contain three values, $t_i$, $p_i$ and $v_i$, where $t_i$ ($1 \leq t_i \leq N$) is the number of the team which had this action, $p_i$ ($1 \leq p_i \leq P$) is the problem number they submitted on, $v_i$ is the verdict they got ($0$ for rejected and $1$ 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

- $1 \leq N , P \leq 100$
- $1 \leq Q \leq 10^{4}$

# | Points | Restrictions |
---|---|---|

1 | 30 | $1 \leq M,P \leq 50$ |

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 |