cho.sh
Notes
Loading...

Temporary Class President

Time limit

2s

Memory limit

128 MB

Problem

A teacher wants to choose a temporary class president until the students in the new sixth-grade class become more familiar with one another. The temporary president should be the student who has shared a class with the largest number of other students at least once from grades 1 through 5.

For each student, a table shows which class they belonged to in each grade from 1 through 5. Consider the following situation with 5 students.

Grade 1Grade 2Grade 3Grade 4Grade 5
Student 123173
Student 241968
Student 355244
Student 465267
Student 584222

Student 4 was in the same class as student 3 in grade 2, in the same class as students 3 and 5 in grade 3, and in the same class as student 2 in grade 4. Therefore, the students who shared a class with student 4 at least once are students 2, 3, and 5, for a total of 3 students. In this situation, student 4 has the largest such count and becomes the temporary class president.

Given the class information for each student from grades 1 through 5, determine the student number of the temporary class president.

Input

The first line contains an integer N, the number of students in the class. N is between 3 and 1000, inclusive.

Each of the next N lines describes one student, from student 1 through student N in order. Each line contains 5 integers separated by spaces: the class numbers that the student belonged to from grades 1 through 5. Every class number is an integer from 1 to 9.

Output

Print the student number of the temporary class president. If more than one student can be chosen, print the smallest student number among them.