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

Задача 39498. Concert hall


The concert venue stores data about sold tickets and available seats. Information about which places are free is known. It is necessary to purchase 5 tickets for the event, and so that all the seats are in the same row and go in a row. Find the lowest numbered row that has five adjacent free spaces. It is guaranteed that there is at least one series that satisfies this condition. In your answer, write down two integers, on one line separated by a space: the minimum number of the row and the largest number of the place from the suitable free places found in this row.
 

Input

The first line of the input file 26.txt contains the number N – the number of vacancies (a natural number not exceeding 10,000). Each of the following N lines contains two natural numbers not exceeding 100,000: the number of the row and the number of the free space.

Imprint
Two non-negative integers: The minimum number of the row where the places indicated in the problem were found and the maximum number of a suitable empty place in this row.
 

Example input file

6
1 1
1 2
1 3
14
15
16



Assignment file