277 传统题

[ABC251C] 诗歌评测最佳原创 (Poem Online Judge)

时间限制
2000ms
内存限制
256MiB
登顶 / 尝试
0/ 0
难度
2

[ABC251C] 诗歌评测最佳原创 (Poem Online Judge)

Problem Statement

Poem Online Judge (POJ) is an online judge that gives scores to submitted strings.

There were NN submissions to POJ. In the ii-th earliest submission, string SiS_i was submitted, and a score of TiT_i was given. (The same string may have been submitted multiple times.)

Note that POJ may not necessarily give the same score to submissions with the same string.

A submission is said to be an original submission if the string in the submission is never submitted in any earlier submission.

A submission is said to be the best submission if it is an original submission with the highest score. If there are multiple such submissions, only the earliest one is considered the best submission.

Find the index of the best submission.

Input

Input is given from Standard Input in the following format:

$N$
$S_1$ $T_1$
$S_2$ $T_2$
$\vdots$
$S_N$ $T_N$

Output

Print the answer.

Example

3
aaa 10
bbb 20
aaa 30
2

Note

  • Constraints:

  • 1≤N≤1051 \leq N \leq 10^5

  • SiS_i is a string consisting of lowercase English characters.

  • SiS_i has a length between 11 and 1010, inclusive.

  • 0≤Ti≤1090 \leq T_i \leq 10^9

  • NN and TiT_i are integers.

  • Source: ABC251C