Problem2309--Poem Online Judge

2309: Poem Online Judge

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MB

Description

Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 300300 points

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 S_iSi was submitted, and a score of T_iTi 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.

Constraints

  • 1 \leq N \leq 1000001N100000
  • S_iSi is a string consisting of lowercase English characters.
  • S_iSi has a length between 11 and 1010, inclusive.
  • 0 \leq T_i \leq 10^90Ti109
  • NN and T_iTi are integers.

Input

Input is given from Standard Input in the following format:
NNS_1S1T_1T1S_2S2T_2T2\vdotsS_NSNT_NTN

Output

Print the answer.

Sample Input Copy

3
aaa 10
bbb 20
aaa 30

Sample Output Copy

2

HINT

We will refer to the ii-th earliest submission as Submission ii.
Original submissions are Submissions 11 and 22. Submission 33 is not original because it has the same string as that in Submission 11.
Among the original submissions, Submission 22 has the highest score. Therefore, this is the best submission.

Source/Category