#C7702. Most Common City
Most Common City
Most Common City
You are given an integer n and n lines each containing a person's name and their city separated by a space. Your task is to determine the most common city among the people. In the event of a tie (i.e. two or more cities have the same highest frequency), return the city that is smallest in lexicographical order.
Formally, if your list of cities is \(\{c_1, c_2, \dots, c_n\}\) and the frequency of a city \(c\) is \(f(c)\), then you need to find the city \(c^*\) such that:
[ c^* = \min { c \mid f(c) = \max_{1 \le i \le n} f(c_i) } ]
It is guaranteed that there is at least one city in every test case.
inputFormat
The first line contains an integer n, representing the number of people.
The following n lines each contain two strings: a person's name followed by the city name (separated by a space).
outputFormat
Output a single line containing the name of the city that is the most common. In case of ties, output the lexicographically smallest city among those.
## sample3
Alice NewYork
Bob NewYork
Charlie NewYork
NewYork
</p>