#K42832. Most Popular Preference
Most Popular Preference
Most Popular Preference
You are given a list of users and their ordered preferences. For each user, only the first element in the list (i.e. their top preference) is considered. Your task is to determine the most popular preference across all users.
The most popular preference is defined as the one that appears as the first choice for the maximum number of users. In the event of a tie, choose the preference with the smallest numerical value.
Note: The constraints are given by \(1 \le n \le 200000\) and \(1 \le m \le 100\), where \(n\) is the number of users and \(m\) is the number of preferences for each user.
inputFormat
The input is given from stdin in the following format:
n m a11 a12 ... a1m a21 a22 ... a2m ... an1 an2 ... anm
Here, the first line contains two integers \(n\) and \(m\). Each of the next \(n\) lines contains \(m\) integers representing the preferences of a user.
outputFormat
Output to stdout a single integer, which is the id of the most popular preference determined based on the rules described above.
## sample1 1
1
1
</p>