#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"

NN rats migrate to a new habitat. There are exactly NN holes which lie on a line one by one. The holes are numbered (starting from the leftmost one) from 11 to nn. 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 [s,t][s,t], 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 KK 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 [s,t][s,t], it could extend the interval with KK more hole. After training, the intervals this rat interest will be [sa,t+b][s-a,t+b] (a+bka+b\leq k, 0ak0\leq a\leq k, 0bk0\leq b\leq k).

Because training these rats to expand their habitat's scope is very hard, RectaFlex wants to know the minimum KK.

Input

There are multiple test cases. The first line of the input will be an integer TT (T20T \leq 20) indicating the number of test cases.

For each test case there is an integer NN (1N5001 \leq N \leq 500) in a single line, representing the number of holes (i.e. the number of rats). The holes are numbered from 11 to NN. Then follows NN lines, each contains two integers LiL_i and RiR_i (1LiRiN1 \leq L_i \leq R_i \leq N), indicating the interest interval of the ithi_{th} rat (inclusive).

Output

For each test case, print Case #t: first, in which tt is the number of the test case starting from 11. Then output the minimum KK.

Samples

输入数据 1

5
2
1 1
1 1
5
1 1
1 1
5 5
5 5
5 5
3
1 1
2 2
3 3
4
1 1
1 2
2 3
3 4
4
1 1
1 2
1 1
1 4

输出数据 1

Case #1: 1
Case #2: 2
Case #3: 0
Case #4: 0
Case #5: 1

Note

In the first case, expanding the intervals to be [1,2][1,2] guarantees each rat a hole.

Resources

10th UESTC Programming Contest Final