G :: Guarding the columns
Time Limit: 8 Seconds Memory Limit: 65536 KB
Persepolis is one of the historical and fascinating sites in Iran. As you know, there are numerous columns of stone in this capital of the great ancient Iran. More specifically, there are K columns in Persepolis that have circular, rectangular and triangular bases. These columns are built perfectly straight. In other words, if you look at them from sky you may only see the perimeter of their bases. Also, some of these columns may have intersections as depicted in the following figure.
The men in charge of maintenance of columns want to create a safe area around columns. For this purpose they have planted a number of N rods (small irony columns) in the ground. They start from a specific rod, tie the rope to it and continue by tying the rope to the next rod and so until they reach the first rod again. The rope between two consecutive rods should be fully straight, but it can touch the columns. Consequently one safe and closed area will be formed around all columns in it.
Now the maintenance team wants to know if it is possible to create the safe surrounding using only the existing rods. If it is possible, find is the minimum length of the rope needed to create it? Note that all columns must be surrounded in one connected safe area.
Input
The first line contains an integer T (T ≤ 100), the number of test cases. The first line of each test contains integer N (3 ≤ N ≤ 300), the number of rods. Then N lines follow, i‐th of which contains two integers xi, yi, the coordinates of i‐th rod.
In the next line there is an integer K (1 ≤ K ≤ 300), the number of columns. Then K lines follow, each line represent one of the columns. i‐th of these lines starts with a character B. If B is equal to ‘C’, it means the column’s base is a circle and it follows with three integers x, y, r (1 ≤ r ≤ 104) —the coordinates of center and the radius of the base of column, respectively. If B is equal to ‘T’ it means the column’s base is a triangle and it follows with six integers x1, y1, x2, y2, x3, y3 that represent the coordinates of vertices of column’s base. And if B is equal to ‘R’ it means the column’s base is a rectangle and it follows with four integers x1, y1, x2, y2 the coordinates of the lower left and the upper right vertices of the base of column, respectively.
All coordinates are integers with their absolute values less than or equal to 10000. Also rods are different and do not coincide with columns. All columns have positive area.
Output
Sample Input
2 4 2 2 6 2 5 5 3 5 1 C 4 3 1 5 6 4 9 8 8 9 3 9 3 8 3 C 6 7 1 T 5 8 7 8 6 9 R 4 6 6 9
Sample Output
12.325 ImpossibleSubmit
Source: AUT 2012