The Hypnotic Spirals

Professor Parinita Pratim Das, a brilliant Mathematician of this era, dreams of winning the Fields Medal someday for her patented Spi- rals that are custom made to hypnotize Engi- neers. To show that her ideas actually work she wants to paint her office room walls with various shapes of spirals. Her method of drawing spirals goes some- thing like this: • She picks a spiral (in polar coordinates) of the form, r = aθ • Then she adds n rays shooting out from the origin — the i-th ray being of the form θ = bi (positive or counter clockwise angle with the x axis) • Finally she marks out m points (rj , θj ) — if a point is in a bounded region then that entire region will be painted black. The spiral on the right is one such example. The following figure illustrates the construction steps of this spiral. Professor Das computes r in meters and knows that she needs 1 liter of black paint for per 10 meter2 area on the wall. She needs your help to calculate how much paint she needs to buy. Input The input for this problem starts with S (S ≤ 100), the number of spirals Professor Das wants to paint. Each of the hypnotic spirals is described in three lines. The first line of a spiral’s description gives a floating point number giving the value of a (0 < a < 10).

2/2 The next line starts with the value of integer n (0 ≤ n ≤ 10). Then follows n floating-point number θi, 0 ≤ θi < 2π, each giving the θ values for the n rays. You can assume that all the θi values are unique (Differs by at least 0.01). The last line of spiral’s description start with the value of m (0 ≤ m ≤ 1000). The next m pairs of floating-point numbers, (rj,θj), 0 < rj < 100, 0 ≤ θj < 2π, in the line gives the coordinates of the points which Professor Das mark out for painting. You can assume that none of the points will be on the spiral’s curve or on any of the rays. Note that all the θ values in the input will be given in radians. Output For each test case print the spiral’s number (in the format shown in the sample output). Then print the amount of black paint (in liters, rounded to 4 digits after the decimal point) needed to paint that spiral on Professor Das’ wall. If the region to be painted is unbounded, print a ‘-1’ instead. The amount of black paint will be such that an error of 5 × 10−8 will not change the printed output. Sample Input 2 1.00 2 0.43 0.78 1 11.06 0.63 1.00 0 2 17.05 0.55 17.59 0.74 Sample Output Spiral 1: 2.2057 liters Spiral 2: -1