Олимпиадный тренинг

Задача 39225. super stadium


The planet Bluk is home to the largest super stadium in the galaxy. In the super stadium 10,000 rows, numbered starting from 1. In each row  10 000 places numbered starting from 1. To date, the Superstar concert has sold N tickets. The file contains information about sold tickets: row number and seat number in this row. Determine which row has the most vacant seats adjacent to each other. If there are the same number of such seats in several rows, then indicate the minimum number of the row. And also indicate the minimum number of the place from which such free places begin. 

Input
The first line of the input file contains an integer N – the total number of tickets sold. Each of the following N lines contains 2 integers: the row number and the position number in this row.

In your answer, write down two integers: the number of the row that has the most empty seats next to it, then – the minimum number of the place from which such free places begin.

An example of the organization of the initial data in the input file (with 5 rows and 5 places in a row):

17
1 2
23
24
3 1
3 2
4 1
4 2
4 3
5 1
5 5
5 4
5 2
5 3
34
3 5
4 5
15


Response: 1 3

Assignment file