#K81457. Find an Intersection Interval

    ID: 35757 Type: Default 1000ms 256MiB

Find an Intersection Interval

Find an Intersection Interval

You are given nn closed intervals on the integer number line. Each interval is defined by its endpoints [ai,bi][a_i, b_i], where aia_i and bib_i are integers and the interval includes all integers xx such that aixbia_i \le x \le b_i. You are also given an integer kk. Your task is to find an integer xx such that xx lies in at least kk of the given intervals. If there are multiple valid answers, you may output any one of them. The answer should be presented as an interval with identical endpoints, i.e. (x,x)(x, x).

For example, consider the intervals [1,5][1,5], [4,8][4,8], and [6,10][6,10] with k=2k=2. The integer 44 is contained in at least two intervals, so the output can be (4,4)(4,4).

inputFormat

The input is read from standard input (stdin) and has the following format:

The first line contains two integers nn and kk, where nn is the number of intervals and kk is the required number of intervals that must intersect at a point. The next nn lines each contain two integers aia_i and bib_i, representing the endpoints of the ii-th interval.

outputFormat

Output a single line to standard output (stdout) containing two identical integers separated by a space, representing an interval (x,x)(x, x) where xx is an integer that lies in at least kk intervals.## sample

3 2
1 5
4 8
6 10
4 4

</p>