#C6509. Most Popular Station
Most Popular Station
Most Popular Station
You are given a railway system with n stations (numbered from 1 to n) and m tickets. Each ticket covers a consecutive range of stations. For example, a ticket represented by a pair (a, b) covers all stations from a to b (inclusive).
Your task is to determine the station that appears on the maximum number of tickets. In case there are multiple stations with the same maximum count, output the smallest station number among them.
Input/Output Example:
Input: 5 3
1 3
2 4
1 5
Output: 2
inputFormat
The input is read from standard input. The first line contains two space-separated integers n and m, where n is the number of stations and m is the number of tickets.
Each of the following m lines contains two space-separated integers a and b. Each pair (a, b) represents a ticket that covers the stations from a to b (inclusive).
outputFormat
Print to standard output a single integer — the station number that appears on the maximum number of tickets. If there are multiple such stations, print the smallest one.
## sample5 3
1 3
2 4
1 5
2