eolymp
bolt
Try our new interface for solving problems
Problems

Lazy visitor

Lazy visitor

One lazy programmer decided to visit the N events. He was so lazy, and it was hard for him to leave his house. Given the fact that he was also a clever programmer, and he decided to do the dodge. He has a list of all events that are planned in the near future, as well as the beginning and end of each event. But he was too busy (so at each event it is delayed for a few seconds, which can be neglected (ie take a point on a temporary line). Your task is to find the minimum number of K - the minimum number of times that he want to leave the house to visit all N events. and K lists showing what events he will visit with each exit from the house. The input file contains several test. In the first line of each test record number 1  N  100. The second line - only the number of N (2  N < 100 000). Then in the next N lines written on two whole numbers, the module does not exceed 2*10^6: L and R (L  R) - the beginning and end events, respectively. For each test case for each exit from the house print in ascending order the number of visited events (separated by the space). At the end of each test set in a single line print “Result = X”, where X - number of exits from the house (without quotes).
Time limit 1 second
Memory limit 64 MiB
Input example #1
1
5
-5 2
-10 0
3 6
5 7
4 8
Output example #1
1 2
3 4 5
Result = 2