#D7837. Universal and Existential Quantifiers
Universal and Existential Quantifiers
Universal and Existential Quantifiers
Problem Statement
You are given a list of intervals. The -th interval is , which denotes a range of numbers greater than or equal to and strictly less than . In this task, you consider the following two numbers:
- The minimum integer such that you can select intervals from the given intervals so that the union of the selected intervals is .
- The minimum integer such that for all possible combinations of intervals from the given interval, it does cover .
We ask you to write a program to compute these two numbers.
Input
The input consists of a single test case formatted as follows.
The first line contains two integers () and (), where is the number of intervals and is the length of range to be covered, respectively. The -th of the following lines contains two integers and (), representing the range of the -th interval . You can assume that the union of all the intervals is
Output
Output two integers and mentioned in the problem statement, separated by a single space, in a line.
Examples
Input | Output |
---|
3 3 0 2 1 3 1 2
|
2 3
2 4 0 4 0 4
|
1 1
5 4 0 2 2 4 0 3 1 3 3 4
|
2 4
Example
Input
Output
inputFormat
Input
The input consists of a single test case formatted as follows.
The first line contains two integers () and (), where is the number of intervals and is the length of range to be covered, respectively. The -th of the following lines contains two integers and (), representing the range of the -th interval . You can assume that the union of all the intervals is
outputFormat
Output
Output two integers and mentioned in the problem statement, separated by a single space, in a line.
Examples
Input | Output |
---|
3 3 0 2 1 3 1 2
|
2 3
2 4 0 4 0 4
|
1 1
5 4 0 2 2 4 0 3 1 3 3 4
|
2 4
Example
Input
Output
样例