
A simple task! You are given the end points of some line segments. Just draw them. Too easy, right?
You decide to challenge yourself and therefore add some constraints.
Start from the end point of any line segment.
Do not lift your pen off the paper.
You can go over a line more than once.
Do not draw any line other than the given ones.
You can only change direction at integer values of and .
Use the minimum amount of ink needed.
You need unit of ink to draw one unit of line. The distance between neighboring points is unit.
So the distance (from to ) = unit, and the distance (from to ) = unit.
The first line contains an integer (T < 20) indicating the number of test cases. Each test case starts with a line containing the number of segments (N < 10). The next lines describe the segments. Each segment is given by two points: and . and are in the range . and are in the range . The first test case corresponds to the figure above. Pay attention to the input format.
For each test case, print on a separate line the minimum amount of ink required to draw, rounded to two decimal places. If it is impossible to complete the drawing without lifting the pen, print x( (see output sample).
Example 1