Welcome to ZOJ
Information
Select Problem
Runs
Ranklist
ZOJ Problem Set - 3598
Spherical Triangle

Time Limit: 2 Seconds      Memory Limit: 65536 KB

As everybody knows, the sum of the interior angles of a triangle on a plane is always 180 degree. But this is not true when the triangle is on spherical surface. Given a triangle on a spherical surface, you are asked to calculate the sum of the interior angles of the triangle.

picture

Formally, you are given the 3 vertex of the triangle. They are connected by the arcs of the great circles, i.e. circles whose centers coincide with the center of the sphere. It is guaranteed that the triangle is not degenerate, i.e. the 3 vertices will not lie on one great circle and no two vertices collide. The interior of the triangle is defined as the smaller part that the triangle is divide into.

Input

There are multiple test cases. The first line of input contains an integer T (0 < T ≤ 2012) indicating the number of test cases. Then T test cases follow.

Each test case contains 3 lines, indicating the position of the 3 vertices. Each line contains 2 real number, each of which contains at most 2 digits after the decimal point, indicating the longitude and the latitude of the vertex. The longitude and the latitude are measured in degree. The longitude will be in (-180, 180] while the latitude will be in [-90, 90].

Output

For each test case, output the sum of the interior angles of the triangle measured in degree, accurate to 0.01.

Sample Input

1
0 0
90 0
0 90

Sample Output

270.00

References


Author: GUAN, Yao
Contest: The 12th Zhejiang University Programming Contest
Submit    Status