Problem H

Find the Point

Input: standard input
Output: standard output

Time Limit: 2 seconds

 

In the picture below you can see a triangle ABC. A point O is inside the triangle ABC. Given the angles AOB, BOC and COA and the coordinates of point A (x1,y1), B(x2,y2) and C(x3,y3) your task is to find the coordinate of point O.


Input

The input file contains less than 1001 sets of input. The description of each set of input is given below:

 

Each set of input is expanded in two lines. First line contains six integers x1, y1, x2, y2, x3, y3 (-200 <= x1, y1, x2, y2, x3, y3 <=200). The meanings of these integers are given in the problem statement and picture above. The second line contains three integers, which denotes the values of angles AOB, BOC and COA respectively in degree.

 

There will be no such input where A, B and C are collinear. Point A, B and C are always different. Input is terminated by a set where A, B, C are all at the origin. Of course this case should not be processed. In this problem if two values differ by less than 1e-8 then they are equal.

 

Output

For each set of input you should produce two lines of output. First line contains the serial of output as shown in the output for sample input. The next line should contain two floating-point numbers Ox and Oy, which denotes the abscissa and ordinate of point O respectively. These floating-point numbers should have six digits after the decimal point. If there is no such point O strictly inside the triangle print a line “IMPOSSIBLE” instead. Errors less than 2e-6 will be ignored.

 

 

Sample Input                              Output for Sample Input

10 10 20 20 5 8

100 200 200

0 0 10 0 5 5

120 120 120

0 0 0 0 0 0

100 100 160

Case 1:

IMPOSSIBLE

Case 2:

5.000000 2.886751

 


Problemsetter: Shahriar Manzoor, Member of Elite Problem Setters’ Panel
Special thanks to Derek Kisman, Member of Elite Problem Setters’ Panel