310548: CF1850B. Ten Words of Wisdom

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:6 Solved:0

Description

B. Ten Words of Wisdomtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

In the game show "Ten Words of Wisdom", there are $n$ participants numbered from $1$ to $n$, each of whom submits one response. The $i$-th response is $a_i$ words long and has quality $b_i$. No two responses have the same quality, and at least one response has length at most $10$.

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

Input

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

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

Then $n$ lines follow, the $i$-th of which contains two integers $a_i$ and $b_i$ ($1 \leq a_i, b_i \leq 50$) — the number of words and the quality of the $i$-th response, respectively.

Additional constraints on the input: in each test case, at least one value of $i$ satisfies $a_i \leq 10$, and all values of $b_i$ are distinct.

Output

For each test case, output a single line containing one integer $x$ ($1 \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.

ExampleInput
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
Note

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

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

We can see that the responses with indices $1$, $3$, $4$, and $5$ have lengths not exceeding $10$ words. Out of these responses, the winner is the one with the highest quality.

Comparing the qualities, we find that:

  • 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.

Input

题意翻译

在一个比赛中,有 $ n $ 个参赛者,每个人都提交了一个回复,长度为 $ a_i $,回复的质量为 $ b_i $,在所有回复长度不超过 $ 10 $ 的回复中,找出质量最好的那一个人的编号。

Output

题目大意:
在智力游戏节目“Ten Words of Wisdom”中,有n个参与者,编号从1到n,每个人都提交一个回答。第i个回答由a_i个单词组成,质量为b_i。没有两个回答具有相同的质量,至少有一个回答的长度不超过10个单词。

节目的获胜者是所有不超过10个单词的回答中质量最高的那个。哪个回答是获胜者?

输入输出数据格式:
输入:
- 第一行包含一个整数t(1≤t≤100)——测试用例的数量。
- 每个测试用例的第一行包含一个整数n(1≤n≤50)——回答的数量。
- 接下来n行,第i行包含两个整数a_i和b_i(1≤a_i, b_i≤50)——第i个回答的单词数量和质量。
- 输入的额外限制:在每个测试用例中,至少有一个i满足a_i≤10,且所有b_i的值都是不同的。

输出:
- 对于每个测试用例,输出一个包含单个整数x的行——根据题目描述的规则,该测试用例的获胜者。题目大意: 在智力游戏节目“Ten Words of Wisdom”中,有n个参与者,编号从1到n,每个人都提交一个回答。第i个回答由a_i个单词组成,质量为b_i。没有两个回答具有相同的质量,至少有一个回答的长度不超过10个单词。 节目的获胜者是所有不超过10个单词的回答中质量最高的那个。哪个回答是获胜者? 输入输出数据格式: 输入: - 第一行包含一个整数t(1≤t≤100)——测试用例的数量。 - 每个测试用例的第一行包含一个整数n(1≤n≤50)——回答的数量。 - 接下来n行,第i行包含两个整数a_i和b_i(1≤a_i, b_i≤50)——第i个回答的单词数量和质量。 - 输入的额外限制:在每个测试用例中,至少有一个i满足a_i≤10,且所有b_i的值都是不同的。 输出: - 对于每个测试用例,输出一个包含单个整数x的行——根据题目描述的规则,该测试用例的获胜者。

加入题单

上一题 下一题 算法标签: