#C7137. Ping Pong Tournament

    ID: 50975 Type: Default 1000ms 256MiB

Ping Pong Tournament

Ping Pong Tournament

John is organizing a ping-pong tournament where every participant plays against every other participant exactly once. Given the outcomes of all matches, you are required to calculate the number of wins and losses for each participant and determine the champion. The champion is defined as the participant with the highest number of wins; in case of a tie, choose the participant with the smallest identifier.

Mathematically, if we denote the wins of each participant as (w_1, w_2, \dots, w_n), then the champion is given by:
(\text{champion} = \min{ i \mid w_i = \max_{1 \leq j \leq n}w_j }).

inputFormat

The first line contains a single integer (n) representing the number of participants. This is followed by (\frac{n(n-1)}{2}) lines, each containing two space-separated integers (a) and (b), representing that participant (a) won against participant (b).

outputFormat

Print three lines. The first line contains (n) space-separated integers representing the win count for each participant (1-indexed). The second line contains (n) space-separated integers representing the loss count for each participant. The third line contains a single integer, the identifier of the tournament champion.## sample

4
1 2
1 3
1 4
2 3
2 4
3 4
3 2 1 0

0 1 2 3 1

</p>