This page is still under construction.

Parts of this page are still being built. What you see may change.

Recommend the Next Morgorithm President

Interview

Time limit1sMemory limit1024 MB

Summary
Given N distinct names with scores, print the name with the highest score, breaking ties by lexicographically smallest name.
Level

Easy2 of 10

Topics
Implementation, Sorting, String
Solved
No attempts yet

Problem

Gukryeol needs to find the next president of Morgorithm quickly. Otherwise, he will have to serve as president even in graduate school.

So Gukryeol tried to hold the 2020 Yonsei University Programming Contest to choose the next president, but the contest was postponed because of COVID-19 and ended up being held in November.

Gukryeol wants to force the person with the highest score among the contest participants to become the next president. If two or more people have the highest score, the person whose name comes first in lexicographic order will be chosen as the next president.

Determine who will be chosen as the next president.

Input

The input is given as follows.

N
A1 B1
. . . . . .
AN BN

Output

On the first line, print the name of the person who will be chosen as the next president.

Constraints

  • 1 ≤ N ≤ 100,000. N is a positive integer representing the number of people.
  • Ai is a string of lowercase English letters with length between 1 and 10, and it is the name of a participant. (1 ≤ i ≤ N)
  • Ai ≠ Aj (1 ≤ i < j ≤ N)
  • 1 ≤ Bi ≤ 1,000,000,000 (1 ≤ i ≤ N). Bi is a positive integer representing a score.

Examples2

  1. Example 1

    Input
    3
    inseop 10
    gukryeol 1
    juno 11
    
    Expected output
    juno
    
  2. Example 2

    Input
    3
    inseop 10
    gukryeol 10
    juno 10
    
    Expected output
    gukryeol