eolymp
bolt
Try our new interface for solving problems
Problems

Favorite game

Favorite game

During his life, Stepan played in a lot of games. One day, he decided to find out what kind of game he most liked. For this, he decided to count the total time spent for each game. The one for which he had spent the greatest amount of time, is his favorite.

Fortunately, Stepan has his daily diary, where he records the number of minutes spent for each game. Therefore, it is not difficult to find a game in which he played the most time in total. For simplicity, Stepan numbered all the games with integers.

It is guaranteed that Stepan has only one favorite game.

Input

The first line contains the number of records n (1n1000) in Stepan's diary. Each of the next n lines contain one record - the pair of numbers xi, yi showing that Stepan was in a game xi exactly yi minutes (1xi, yi1000).

Output

Print one number - the number of Stepan's favorite game.

Time limit 1 second
Memory limit 128 MiB
Input example #1
3
1 10
2 20
1 5
Output example #1
2
Input example #2
4
1 10
3 31
1 20
2 25
Output example #2
3
Input example #3
10
7 659
10 428
5 357
8 528
5 425
5 349
9 206
4 153
7 640
3 250
Output example #3
7
Source ACM-ICPC Ukraine 2015, Первый этап Украина, 25 апреля 2015 года