Polygonal Park

When Polygonal Town was built, in its center it was left a rectan- gular space to built a park. However, there was a serious problems in the construction and many houses were built over the park space. More exactly, every limit of the park was invaded with two types of houses: Houses with square base and houses with equilateral triangle base, as you can see in the following picture (The white squares and triangles are houses). The mayor of Polygonal Town has decided to left the houses in their actual location and build the park in the free space left (the grey area in the picture). Can you calculate the area of the park? It is guaranteed that in the four corners of the park are square houses, that the consecutive houses are always together and that no house overlaps other. Input The first line of the input contains an integer T, the number of test cases. Each case begins with an integer N (4 ≤ N ≤ 3100), the number of houses located in the original park space. Next there are N lines, each one representing a house. The first line of this N lines will represent the house located at the upper left corner and all the other houses will appear clockwise. Each one of the lines that represents a house contains a character C and a number K (1 ≤ K ≤ 1500). The character C can has the value of ‘S’ if it is a square house, ‘T’ if if its a triangle house or ‘C’ if it is a corner house (remember that if the house is corner, it will be a square house). The number K is the length in meters of one side of the house. Output For each test case prints a single line with the area of the park in meters. This number has to have four digits after the decimal point. Sample Input 1 8 C4 T3 C3 S2 C4 S2 C4 T1 Sample Output 20.6699