Time limit
2s
Memory limit
128 MB
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 1 | Grade 2 | Grade 3 | Grade 4 | Grade 5 | |
|---|---|---|---|---|---|
| Student 1 | 2 | 3 | 1 | 7 | 3 |
| Student 2 | 4 | 1 | 9 | 6 | 8 |
| Student 3 | 5 | 5 | 2 | 4 | 4 |
| Student 4 | 6 | 5 | 2 | 6 | 7 |
| Student 5 | 8 | 4 | 2 | 2 | 2 |
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.
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.
Print the student number of the temporary class president. If more than one student can be chosen, print the smallest student number among them.