#P6444. [COCI 2010/2011 #1] PROFESOR

[COCI 2010/2011 #1] PROFESOR

Problem Description

In a long classroom, there are nn desks in a single row, and each desk has 22 students sitting at it. The students are daydreaming because they are about to have an art class, and their professor is planning to test them.

Each student has learned art, but only up to a certain level. The professor can tell how much they have learned by the look on their faces. The professor is an artist, and each grade uses colored pencils of different colors. Unfortunately, today he brought only 11 pencil.

To make the test seem fair, he wants to choose 22 desks, and ask 11 student from every desk between the two chosen desks (including the chosen desks). It is important that all tested students receive the same grade, so that he can write it down with the single pencil.

The professor wants to know the maximum number of students he can test in this way, and what grade the students will receive.

Input Format

The input has n+1n + 1 lines.

The first line contains an integer nn, as described above.

The next nn lines each contain two integers: aia_i and bib_i, which are the grades of the students sitting at desk ii.

Output Format

Output one line.

Print 22 numbers separated by a single space: the maximum number of students the professor can test, and the grade those students will receive.

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

1
1 5 

1 1

3
3 5
4 5
1 3 

2 5

4
2 1
3 2
5 3
2 5 

2 2

Hint

Constraints

For 100%100\% of the testdata, 1n1051 \le n \le 10^5, 1ai,bi51 \le a_i, b_i \leq 5.

Notes

Translated from COCI2010-2011 CONTEST #1 T2 PROFESOR.

Translated by ChatGPT 5