Problem I
Wind of Change!
Input: Standard Input

Output: Standard Output

 

Take me to the magic of the moment
On a glory night
Where the children of tomorrow dream away
In the wind of change

 

While advancing through the tunnel of time we have observed that many of the peace processes have failed just because the intension of many were only to show that they want peace rather than actually establishing the peace itself. As some of the peace loving people of the World look behind they discover that they were happier when there were no engines, planes and other fuel driven machineries. All these have happened because while science has progressed humanity has not. So now they decide that they will all go back to the ancient stages, which means they will not use any modern equipments. The only modern equipment they will use is a computer (run by solar power). The UN has allotted a large area for them (which does not have any natural resources other than animals and trees) to live peacefully. These peace-loving peoples begin their new life with the hope that no one will disturb them. These peoples do not have any atlas so the first trouble they face is determining their own positions. The method they use to determine their latitude is as the following:

 

Let the place whose latitude is to be determined is A. They start from A and goes n km to the north, then they go n km to the east, then they go n km to the south and finally they go m km to the west to reach A again. They find the latitude from the values of m and n. You can assume: 

a)      The latitude of the place A is within 0 to 70 degree North.

b)      The value of n is less than 1001 km.

 

Input

The first line of the input file contains an integer N (N<=5000) that indicates how many sets of inputs are there.  Each of the next N lines makes a set of input. Each set contains two floating-point numbers n and m (n<m).

 

Output 

For each set of input you should produce one line of output. This line contains the input serial number and then the latitude of A expressed in nearest degree, minute and second as shown in the sample output. If the given input is invalid or it is impossible to determine the latitude of A from the given data then print the line “Invalid or impossible.” instead. An input is invalid when it violates any of the two assumptions above. You can further assume that the earth is a perfect sphere, pi=2*cos-1(0) and the radius of earth is exactly 6378 km.

 

Sample Input                               Output for Sample Input

3

100.0 102.0

150.0 200.0

1101.0 1102.0

Case 1: 51 deg 10 min 43 sec

Case 2: Invalid or impossible.

Case 3: Invalid or impossible.


Shahriar Manzoor