Limits 1s, 512 MB

Sheldon is kind of a bookworm, literally. While reading a book, he eats the pages on which he saw something interesting. Recently he read a book which had pages numbered from ​ 1 to N. The first page had page numbers "1" on the front and "2" on the back. The next one had "3" on the front and "4" on the back. So on and so forth.

Sheldon remembers intervals of page numbers which he ate in the form of ​ [A, B)​. For example, [1, 5) means he ate pages 1, 2, 3 and 4. [1, 1) means nothing was eaten. He remembers ​ M such intervals. He also remembers that the intervals can overlap. For some reason, from this information, he can not figure out which pages still remains intact on the book. So, he decided to take your help. Your task is to tell Sheldon which pages are still in the book in the form of intervals ​ [A, B)​. You have to provide this information with the minimum number of intervals.

Input

The input file contains multiple test cases. Each test case starts with two numbers, N and M. Each of the following M lines will contain two integers A B, which is one of the intervals that Sheldon remembered.

Constraints:

2 ≤ N ≤ 109 (​ N will always be even ​ ). 0 ≤ M ≤ 2000. 1 ≤ A ≤ B ≤ N+1.
There will be no more than 500 test cases.

Output

For each case, print minimum number of intervals to provide the answer. Intervals will be in the form of ​ [A, B)​ as mentioned in the problem statement. Outputs should be sorted in ascending order. If Sheldon ate the entire book, Print "​ Sheldon ate it all !!! ​ ". Please see the samples for a better understanding.

Samples

InputOutput
1000 1
100 201
1 99
201 1001
InputOutput
100 3
11 21
51 56
54 61
1 11
21 51
61 101
InputOutput
200 1
1 201
Sheldon ate it all !!!

Submit

Login to submit.

Statistics

62% Solution Ratio
RHT_20Earliest, May '18
sajeedreefyFastest, 0.0s
RHT_20Lightest, 131 kB
Riz1ahmedShortest, 776B
Toph uses cookies. By continuing you agree to our Cookie Policy.