#K48302. Find the Team with the Highest Cumulative Score

    ID: 28390 Type: Default 1000ms 256MiB

Find the Team with the Highest Cumulative Score

Find the Team with the Highest Cumulative Score

You are given n teams and the results of m matches between them. Each match is described by four integers:

  • i: the identifier of the first team
  • j: the identifier of the second team
  • scorei: the score obtained by team i in the match
  • scorej: the score obtained by team j in the match

Your task is to compute the cumulative score for each team and return the identifier of the team with the highest cumulative score. In the case of a tie, return the smallest numerical identifier.

The cumulative score for a team is defined as the sum of all scores that team achieved in all matches.

Note: All input is given via standard input and output should be written to standard output.

inputFormat

The first line of the input contains two integers n and m separated by a space, where:

  • n (1 ≤ n ≤ 105) is the number of teams.
  • m (1 ≤ m ≤ 105) is the number of matches.

The following m lines each contain 4 integers i, j, scorei, and scorej separated by spaces, representing a match between team i and team j with their respective scores.

outputFormat

Output a single integer: the identifier of the team with the highest cumulative score. If there is a tie, output the smallest team identifier.

## sample
3 3
1 2 10 8
1 3 12 5
2 3 9 11
1