Олимпиадный тренинг

Задача 39022. Gymnastic ribbons. Training task - 3


For the performance, the gymnasts use ribbons, which are placed on the table after the performance. The father of the best gymnast Anna K., in anticipation of the award, decided to write down the coordinates of the beginning and end of the ribbons. Do you have a file with this information. Determine at how many points of the table the greatest thickness of the coating turned out and what it is equal to. The table has a length Lmm. At the end of the performance of all the gymnasts, there was N ribbons. No ribbon protrudes beyond the table. All ribbons lie horizontally. The ribbons stack on top of each other. 
 
Input
The first line of the file contains two numbers - L, N (1 <= L <= 10000, 1 <= N <= 10000). The following lines contain 2 numbers each - l, r (1 <= l <= r < = L) - left and right ends of ribbons relative to the left edge of the table.

In your answer, indicate two numbers separated by a space - the maximum thickness of the tape table cover and the number of points with such a thickness. 
 
Examples
# Input Output
1
39 4
3 21
3 15
2 20
3 17
4 13


Assignment file

Запрещенные операторы:sort