4.1 Word game
(RankList for this Question)
Score: 10pts
Time Limit: 5.00 sec
In the game show "Ten Words" there are n participants with responses numbered from 1 to n. Each response has two attributes: its length, represented by ai words, and its quality, represented by bi. There are no responses with the same quality, and at least one response has a length of 10 words or less.
To determine the winner of the show, we need to find the response with the highest quality among all responses that are 10 words or less in length. Which response will be declared the winner?

Constraints
1 ≤ t ≤ 100
1 ≤ n ≤ 50
1 ≤ ai, bi ≤ 50

Input Format
The first line contains a single integer t — the number of test cases.

For each test case:
- The first line contains a single integer n — the number of responses.
- Then, n lines follow, where each line contains two integers ai and bi — the number of words and the quality of the i-th response, respectively. It is guaranteed that at least one response has ai ≤ 10, and all values of bi are distinct.

Output Format
For each test case, output a single line containing one integer x (1 ≤ x ≤ n) — the winner of the show, according to the rules given in the statement.

Example 1
Input:
3
5
7 2
12 5
9 3
9 4
10 1
3
1 2
3 4
5 6
1
1 43

Output:
4
3
1

Explanation:
Test Case 1:

Responses Provided:

1. Response 1: 7 words, quality 2
2. Response 2: 12 words, quality 5
3. Response 3: 9 words, quality 3
4. Response 4: 9 words, quality 4
5. Response 5: 10 words, quality 1

Eligible Responses (Length <= 10 words):

1. Response 1: 7 words, quality 2
3. Response 3: 9 words, quality 3
4. Response 4: 9 words, quality 4
5. Response 5: 10 words, quality 1

Winner Determination:

- Response 1 has quality 2.
- Response 3 has quality 3.
- Response 4 has quality 4.
- Response 5 has quality 1.

Among these responses, Response 4 has the highest quality and is declared the winner.

Log In to solve the Question