CF1850B.Ten Words of Wisdom

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Ten Words of Wisdom

In the game show "Ten Words of Wisdom", there are nn participants numbered from 11 to nn, each of whom submits one response. The ii-th response is aia_i words long and has quality bib_i. No two responses have the same quality, and at least one response has length at most 1010.

The winner of the show is the response which has the highest quality out of all responses that are not longer than 1010 words. Which response is the winner?

Input

The first line contains a single integer tt (1t1001 \leq t \leq 100) — the number of test cases.

The first line of each test case contains a single integer nn (1n501 \leq n \leq 50) — the number of responses.

Then nn lines follow, the ii-th of which contains two integers aia_i and bib_i (1ai,bi501 \leq a_i, b_i \leq 50) — the number of words and the quality of the ii-th response, respectively.

Additional constraints on the input: in each test case, at least one value of ii satisfies ai10a_i \leq 10, and all values of bib_i are distinct.

Output

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

It can be shown that, according to the constraints in the statement, exactly one winner exists for each test case.

Note

In the first test case, the responses provided are as follows:

  • Response 1: 77 words, quality 22
  • Response 2: 1212 words, quality 55
  • Response 3: 99 words, quality 33
  • Response 4: 99 words, quality 44
  • Response 5: 1010 words, quality 11

We can see that the responses with indices 11, 33, 44, and 55 have lengths not exceeding 1010 words. Out of these responses, the winner is the one with the highest quality.

Comparing the qualities, we find that:

  • Response 1 has quality 22.
  • Response 3 has quality 33.
  • Response 4 has quality 44.
  • Response 5 has quality 11.

Among these responses, Response 4 has the highest quality.

Samples

3
5
7 2
12 5
9 3
9 4
10 1
3
1 2
3 4
5 6
1
1 43
4
3
1

在线编程 IDE

建议全屏模式获得最佳体验