Volume Measurement

Please look at the picture below: A solid cube is placed within a pyramid shaped frame. The base of the pyramid frame is square ABCD. The length and width of this base is l, (The image below shows l and w. Assume that w equals l) and the height of the pyramid frame is h. The length of one (or all) side of the solid cube is a. Point A is considered the origin, x-axis is along AX and y-axis is along AY. So the coordinates of A, B, C, D are (0, 0), (l, 0), (l, l) and (0, l) respectively. The peak of the pyramid frame is E which is straight above the center of the base ABCD. The center of the base of the cube is O (l/2, l/2) which is also the center of the base of the pyramid and FG makes an angle θ (0 < θ < 90) with x-axis. Surely for many values of a or θ the cube will not fit within the pyramid frame. Your job is to detect situations whether the cube fits within the pyramid and if it does fit then find the volume of the combined object. Figure: A square placed within a pyramid frame. Please note that the image above is not exact with the problem statement. In our problem the length and width of the base of the pyramid are equal (l = w). And in our problem the square is placed right at the center of the base of the pyramid. That is not the case in the figure above. Input The input file contains several sets of input. The first line of the input file contains an integer N that indicates how many sets of input are there. Each of the next N lines contains a single set of input. All numbers in the input are less than 200. Each set contains four positive integers l, h, a, θ. There will be no such inputs which will cause floating-point errors to produce different outputs.

2/2 Output For each set of input you must produce two lines of output. The first line should contain the serial of the output as shown in the output for sample input. If for the given input it is impossible to fit the cube within the pyramid shaped frame (Some parts of the cube may be outside the pyramid keeping the shape of the frame intact) print in the second line ‘IMPOSSIBLE.’. Otherwise in the second line print the volume of the combined object. This volume should have three digits after the decimal point. Sample Input 2 10 10 10 45 10 10 1 50 Sample Output Case 1: IMPOSSIBLE. Case 2: 333.333