#C4998. Top Salesperson Bonus

    ID: 48597 Type: Default 1000ms 256MiB

Top Salesperson Bonus

Top Salesperson Bonus

In a company, each sale is recorded as a pair of integers representing the salesperson's ID and the product's ID. The company has decided to award a special bonus to the salesperson with the highest number of distinct product sales. If two or more salespersons have the same number of distinct sales, the salesperson with the smallest ID should be chosen.

Your task is to write a program that reads the sales records from standard input, determines the top salesperson according to the above criterion, and outputs their ID to standard output.

In mathematical terms, let the list of sales records be given by the array of pairs \( (s_1, p_1), (s_2, p_2), \dots, (s_N, p_N) \) . For each salesperson \(s\), define the set of distinct products sold as \(P_s = \{ p_i : s_i = s \}\). You need to find the salesperson \(s^*\) such that:

[ s^* = \min{ s : |P_s| = \max_{t} |P_t| } ]

Note that the input is provided via standard input and the output should be sent to standard output.

inputFormat

The first line contains a single integer \(N\) representing the number of sales records. The following \(N\) lines each contain two integers separated by a space. The first integer is the salesperson's ID and the second integer is the product's ID.

outputFormat

Output a single integer: the ID of the top salesperson who qualifies for the bonus.

## sample
5
1 101
1 102
2 101
2 103
2 104
2