Jumping Points
题号:NC210081
时间限制:C/C++/Rust/Pascal 4秒,其他语言8秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
Special Judge, 64bit IO Format: %lld

题目描述

Apollo isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the ICPC. Scared, Apollo locked himself in the basement and started thinking of new problems of this kind. One of them is the following.

Given n segments (numbered from 1 to n) in the two dimensional space. The i-th segment connects the points (i, l_i) and (i, r_i). Apollo wants to select n points from the given n segments. The i-th point (x_i, y_i) should lie in the i-th segment. That is say, the i-th points (x_i, y_i) should meet and .
The Euclidean distance between the two points with numbers i and j is said to be: . We say that the length of the path formed by the n points is value .

Apollo gives you the starting and ending points of n segments. You have to find n points for him, to minumize the length of the path formed by the n points.

输入描述:

The first line is an integer  (), which is the number of test cases.
Each test case begins with a line containing a positive integer n () showing the number of segments. The following n lines contain the descriptions of the n segments. Each line contains two integers l_i and r_i () --- the coordinates of the two endpoints for one of the i-th segment are (i, l_i) and (i, r_i).

输出描述:

For each test case, output one line containing "Case #x:", where x is the test case number, and next n lines print the n points that you selected. The i-th line is "x_i y_i", denotes the coordinate of the i-th point.
It may have multiple solutions, you can output any of them. Let the length of your answer be a, and the length of jury's answer be b. Your answer is considered correct, if .
示例1

输入

复制
2
4
1 3
0 2
2 3
1 4
5
1 2
1 3
2 3
3 4
2 4

输出

复制
Case #1:
1 2
2 2
3 2
4 2
Case #2:
1 2.000000
2 2.333333
3 2.666667
4 3.000000
5 3.000000