#C3347. Taco Championship

    ID: 46764 Type: Default 1000ms 256MiB

Taco Championship

Taco Championship

You are given the score results of a taco championship. There are M participants and each participates in N challenges. In the jth challenge, the ith participant earns a score sij.

For each participant i, define the total score as

( S_i = \sum_{j=1}^{N} s_{ij} )

and let \( T_i \) be the list of scores sorted in non-increasing order. The winner is determined by comparing the tuple \( (S_i, T_i) \) in lexicographical order; that is, a participant \( i \) is considered better than participant \( k \) if either:

  • \( S_i > S_k \), or
  • \( S_i = S_k \) and \( T_i \) is lexicographically greater than \( T_k \) (i.e. the highest score is compared first, then the second highest, etc.).

If there is still a complete tie, choose the participant with the smallest index (0-indexed). Your task is to determine the index of the winning participant.

inputFormat

The input is read from stdin and has the following format:

  • The first line contains two integers M and N separated by a space, where M is the number of participants and N is the number of challenges.
  • The next M lines each contain N integers. The ith of these lines represents the scores of the ith participant.

outputFormat

The output should be written to stdout and consists of a single integer: the index (0-indexed) of the winning participant.

## sample
1 3
70 80 90
0