spoj#LCPC12E. Johnnys Empire

Johnnys Empire

Description

Hundreds of years ago Johnny's father had a great kingdom. Before his death he divided his kingdom between his sons (Johnny and Johnny's brother). Johnny's brother took part of the kingdom with a circular shape with radius R.  Jonny took part of kingdom of squared shape with side length L. As Johnny was jealous from his brother after his father's death, he decided to extend his kingdom to be a circle such that the corners of the square lies exactly on the border of the circle. A problem might occur that Johnny could steal some land from his brother, and that could wage a huge war between the two brothers. So Johnny decided to convince his brother to build a wall separating between the two kingdoms. The wall should be connecting the two intersection points between the two circles. You are to estimate the length of this wall.

Input Format

The first line of input contains an integer T, the number of test cases. T test cases follow, the first line of each test case contains 6 floating point numbers; 2 numbers denoting the center of Johnny's brother kingdom, another 2 for the center of Johnny's kingdom, R the radius of Johnny's brother kingdom A, and L the side length of the square of Johnny's kingdom. It’s guaranteed that both kingdoms don’t share any lands originally. Also after kingdom B is extended, it’s guaranteed that the intersection area will not cover Johnny's brother kingdom completely. The absolute value for all decimal numbers will be less than 109.

Output Format

There should be T lines, containing the following format.

k. S

Where k is the test case number (starting at 1), a single period, a single space and S represent a decimal number with exactly 3 digits after the decimal point representing the wall length. If there’s no possibility of war, print “No problem”.

Sample Input

Sample Output

3
0.0 0.0 10.0 0 3 3
0.0 0.0 4.121 0 3 3
-1 3 1 -1 2 7.071
1. No problem
2. 2.971
3. 3.994