#K54827. Most Efficient Participant

    ID: 29840 Type: Default 1000ms 256MiB

Most Efficient Participant

Most Efficient Participant

You are given several test cases. For each test case, the first line contains an integer \(N\), representing the number of participants. Each of the following \(N\) lines contains a sequence of space-separated tokens representing multiple attempts. Each attempt is given by a pair: an integer time and a string result (either AC for accepted or WA for wrong answer).

The objective is to determine, for each test case, which participant achieved the minimum accepted time. If a participant never got an AC, ignore that participant. If none of the participants have an accepted submission, or if more than one participant reaches the same minimum accepted time, output TIE. Otherwise, output the participant number in the format Participant X (where X is the 1-indexed participant number).

Note: All formulas are rendered in \(\LaTeX\) format. In particular, if the minimum accepted time is \(m\), then we are searching for a unique participant such that \(t_i = m\) and for all \(j \neq i,\ t_j \neq m\), where \(t_k\) represents the minimum accepted time for participant \(k\).

inputFormat

The first line of input contains an integer \(T\), the number of test cases. Each test case is formatted as follows:

  • The first line contains an integer \(N\) - the number of participants.
  • Each of the next \(N\) lines contains a variable number of space-separated tokens, representing several pairs. Each pair consists of an integer (the time in minutes) and a string (either AC or WA). The number of tokens on each line is even.

Input is read from standard input (stdin).

outputFormat

For each test case, output a single line:

  • If exactly one participant has the unique minimal accepted time, output Participant X, where X is the 1-indexed participant number.
  • If no participant has an accepted attempt or if multiple participants share the minimal accepted time, output TIE.

Output is written to standard output (stdout).

## sample
6
3
25 AC 30 WA 35 AC
20 WA 15 AC 50 WA
50 WA 45 WA 10 AC
2
40 WA 20 AC
20 AC 40 WA
2
25 WA 30 WA
20 WA 50 WA
1
25 AC 30 WA
3
25 WA 30 AC 35 WA
25 WA 30 AC 50 WA
50 WA 30 AC 10 WA
2
30 AC
20 WA
Participant 3

TIE TIE Participant 1 TIE Participant 1

</p>