Crime at Piccadilly Circus

No attempts yetTime limit1sMemory limit128 MB

Problem

Sherlock Holmes is investigating a crime at Piccadilly Circus. He wants to know the maximum and the minimum number of people who were at the crime scene at the same time during the interval when the crime could have been committed. Scotland Yard interviewed everyone who was seen at the scene and, for each person, established the moment they arrived and the moment they left. Doctor Watson offered to process the data and work out the numbers Holmes is interested in, but he is struggling. Help him.

Time is measured in whole (integer) units. A person who arrived at moment aia_i and left at moment bib_i was present at every integer moment tt with aitbia_i \le t \le b_i. The crime could have been committed at any integer moment tt in the interval [p,k][p, k].

Write a program that:

  • reads from standard input the time interval in which the crime could have been committed and the data gathered by Scotland Yard;
  • determines, within that interval, the minimum (this can be zero) and the maximum number of people who were at the scene at the same moment;
  • writes the results to standard output.

Input

The first line contains two integers pp and kk (0pk1090 \le p \le k \le 10^9): the earliest and the latest moment at which the crime could have been committed.

The second line contains one integer nn (3n50003 \le n \le 5000): the number of people interviewed by Scotland Yard.

Each of the next nn lines contains two integers aia_i and bib_i separated by a single space (0aibi1090 \le a_i \le b_i \le 10^9): the moment the ii-th person arrived at the scene and the moment they left. The ii-th person was present at the scene for the whole time from moment aia_i to moment bib_i inclusive.

Output

Print a single line with two integers separated by a single space: the minimum and the maximum number of people who were at the crime scene at the same moment during the interval from moment pp to moment kk inclusive.