#Lutece0573. Grab a hole
Grab a hole
Migrated from Lutece 573 Grab a hole
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
"One radish, one hole"
rats migrate to a new habitat. There are exactly holes which lie on a line one by one. The holes are numbered (starting from the leftmost one) from to . They don't want to share a hole with others, so every rat should grab a hole as its home. Each rat has an interested interval (we denote it as , in which s and t are the two ends) of holes from which it would choose one to grab. However, a plan that ensures any rats have a hole may not exist.
RectaFlex loves these rats very much. He wants to train these rats to expand their interested interval with more holes. Note that the new expanded interested interval of each rat must still be continuous. If a rat interested in holes which belong to interval , it could extend the interval with more hole. After training, the intervals this rat interest will be (, , ).
Because training these rats to expand their habitat's scope is very hard, RectaFlex wants to know the minimum .
Input
There are multiple test cases. The first line of the input will be an integer () indicating the number of test cases.
For each test case there is an integer () in a single line, representing the number of holes (i.e. the number of rats). The holes are numbered from to . Then follows lines, each contains two integers and (), indicating the interest interval of the rat (inclusive).
Output
For each test case, print Case #t:
first, in which is the number of the test case starting from . Then output the minimum .
Samples
Note
In the first case, expanding the intervals to be guarantees each rat a hole.
Resources
10th UESTC Programming Contest Final