Warm-up
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
Find a pair of numbers, according to a specified output criteria.
Input
In the input file is written first, the number N (1 ≤ N ≤ 100), and then the N pairs of numbers. The first number in each pair - a natural, not exceeding 30000. The second number of each pair - either 0 or 1.
Output
Required to find and display the output file number of the pair, in which the second number is equal to 1, and from all such pairs one in which the first number of the most (if several such pairs, display the first of them).
If the pairs for which the second number is equal to 1 no, output in the output -1.
Examples
Input #1
Answer #1
Submissions 1K
Acceptance rate 48%