#K68637. Highest Average Player Score

    ID: 32909 Type: Default 1000ms 256MiB

Highest Average Player Score

Highest Average Player Score

In this problem, you are given the results of several games played by multiple players. Each game is played according to one of the following rules:

  • Game A: The player's score is given directly (an integer between 0 and 100).
  • Game B: The player throws a die and the score is the result multiplied by 10.
  • Game C: The player answers some questions; each correct answer is worth 5 points. (The input provides the number of correct answers, and the score is computed as (5 \times \text{correct})).

For each test case, you must determine the player (1-indexed) with the highest average score across all games. The average score is computed as: [ \text{average} = \frac{\text{total score}}{G} ] If multiple players obtain the same highest average score, the player with the lowest index should be chosen.

Your program will read from standard input and output the result to standard output. Make sure to adhere to the specified input and output format.

inputFormat

The input consists of multiple test cases formatted as follows:

  • The first line contains an integer (T) representing the number of test cases.
  • For each test case:
    • The first line contains two integers (P) and (G) where (P) is the number of players and (G) is the number of games played.
    • The next (P) lines each describe the scores for a player in the (G) games. Each line contains the scores for the games separated by a comma and a space. The format for each game is:
      • "A score" for Game A
      • "B score" for Game B
      • "C count" for Game C (where the score is computed as (5 \times \text{count})).

Note: There is no extra whitespace besides what is described.

outputFormat

For each test case, output a single line containing the 1-indexed number of the player with the highest average score. If there are multiple players with the same average, output the one with the smallest index.## sample

2
3 3
A 55, B 5, C 7
A 40, B 6, C 8
A 60, B 3, C 10
2 2
A 30, B 2
A 70, B 1
1

2

</p>