Problem M

Rope Crisis in Ropeland !

Input: standard input

Output: standard output

Time Limit: 2 seconds

This is a story of Ropeland where rope pulling is a very popular game (like cricket in Bangladesh). Perhaps you know the game rope pulling: two groups of players hold two ends of a rope. When a certain signal is given they start pulling ropes. The group that can snatch the rope from the other group is declared winner. Today is a very happy day in Ropeland as they have got rope status (something like Bangladesh’s test status). So the people of Ropeland are on the street and they are willing to be engaged in rope pulling. But the shops in the city fail to supply enough rope and so now a rope crisis has begun. The King of the country declares a new rule that two groups will not be allowed to buy more ropes than what they require.

The problem is that rope-pulling takes place in a large hall room that has a large round pillar in the middle with certain radius. So if two groups are on the opposite side of the pillar their pulled rope is never in a straight line. Given the position of the two groups you are to find out the minimum length of rope required by them to start rope-pulling. You can assume that a point represents the position of each group.

 

Fig 1: Situation when two groups have the round pillar between them. The pulled rope is never a straight line

Fig 2: Situation when the two groups don’t have the round pillar between them

Input

The first line of the input file contains an integer N, which tells how many sets of input are there. Next there are N lines of input.

Each line contains five numbers X1, Y1, X2, Y2 and R (> 0) where (X1, Y1) and (X2, Y2) are the coordinates of the two groups and R is the radius of the pillar. The coordinate of the center of the pillar is always the origin. You can also assume that none of the coordinates will be inside the circle. All input numbers except N are floating point numbers and none of their absolute value is greater than 10000.

Output

For each set of input output a floating-point number in a new line rounded to the third digit after the decimal point and this number denotes the minimum length of the rope required.

Sample Input

2
1 1 -1 -1 1
1 1 -1 1 1

Sample Output

3.571
2.000

Rezaul Alam Chowdhury (Idea generator and judge solution writer) & Shahriar Manzoor (Problem statement writer)
 
 

“It may seem weird to many, but there are more triangles

than there are points in this universe.”