#K61272. Team Win-Loss Tally

    ID: 31273 Type: Default 1000ms 256MiB

Team Win-Loss Tally

Team Win-Loss Tally

You are given a tournament with \(N\) teams and \(M\) games. Each game is represented by three integers: team \(i\), team \(j\), and the winner of the match (either \(i\) or \(j\)). Your task is to compute the number of wins and losses for each team.

For each game, if team \(i\) wins, team \(i\) gets one win and team \(j\) gets one loss. Similarly, if team \(j\) wins, team \(j\) gets one win and team \(i\) gets one loss. Formally, if a game is represented by \((i, j, w)\), then:

\[ wins_{i} = wins_{i} + 1 \quad \text{and} \quad losses_{j} = losses_{j} + 1 \quad \text{if} \quad w = i, \] \[ wins_{j} = wins_{j} + 1 \quad \text{and} \quad losses_{i} = losses_{i} + 1 \quad \text{if} \quad w = j. \]

Teams are numbered from 1 to \(N\). Output the records for each team in order from team 1 to team \(N\).

inputFormat

The input begins with a line containing two integers \(N\) and \(M\): the number of teams and the number of games, respectively.

This is followed by \(M\) lines, each containing three integers \(i\), \(j\), and \(w\), where \(i\) and \(j\) are the team numbers involved in the game, and \(w\) is the winner (either \(i\) or \(j\)).

outputFormat

Output \(N\) lines. The \(i\)-th line should contain two space-separated integers representing the number of wins and losses for team \(i\), respectively.

## sample
5 10
1 2 1
1 3 1
1 4 4
1 5 1
2 3 3
2 4 2
2 5 5
3 4 3
3 5 5
4 5 5
3 1

1 3 2 2 1 3 3 1

</p>