#Lutece0493. PROFESOR

PROFESOR

Migrated from Lutece 493 PROFESOR

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

In a long classroom, NN desks are arranged in a single row, with two students sitting at each desk. Students are cranky because they are about to have an art class, and their professor is planning to examine them.

Each student has studied art, but only to a certain level. The old professor can tell by the looks on their faces just how much they have studied. The professor, being an artist, uses a different coloured pencil for each grade. Unfortunately, today he brought only one pencil.

In order to make the examination seem fair, he wants to choose two desks and question one student from each desk positioned between the two desks he has chosen (including the chosen desks). It is important that all examined students deserve the same grades, so he can write them down using his only pencil.

The professor wants to know the maximum number of students he can examine this way, as well as which grade the students will get.

Input

The first line of input contains a single integer NN (1N1000001 \leq N \leq 100 000).

Each of the following NN rows contains two integers: AiA_i and BiB_i, grades deserved by students sitting at desk ii (1Ai,Bi51 \leq A_i, B_i \leq 5).

Output

The first and only line of output must contain two numbers separated by a single space: the maximum number of students the professor can examine and the grade those students will get.

If there are multiple solutions possible, output the one with the smallest grade.

Samples

输入数据 1

1 
1 5

输出数据 1

1 1

输入数据 2

3 
3 5 
4 5 
1 3

输出数据 2

2 5

输入数据 3

4 
2 1 
3 2 
5 3 
2 5

输出数据 3

2 2

Note

Test cases worth 70%70\% of total points have N100N \leq 100.

Resources

COCI 2010/2011, 1st round, October 23rd 2010, Author: Goran Gašić