Broken Nail#4065

Broken Nail

0.4 seconds
16 megabytes
Very hard

A decorative frame is hanging on a vertical wall, secured by two nails.

The frame is a polygon of an arbitrary shape, which includes cutouts, each also being a polygon of arbitrary shape.

If one of the nails breaks, the frame will start to swing around the remaining nail due to gravity. After several oscillations, the frame will settle into a new stable position (refer to the figure).

Your task is to calculate the absolute magnitude of the angle by which the frame rotates from its initial position once it stabilizes.

Notes:

Input

The first line contains a single integer – the number of vertices of the frame (3 \le N \le 50).

The next lines provide the coordinates of the -th vertex of the frame as two integers P_{iX} and P_{iY}, separated by a space (1 \le i \le N, 0 \le P_{iX} \le 100, 0 \le P_{iY} \le 100). The vertices are listed in the order they connect to form the polygon.

The following line contains a single integer – the number of cutouts (0 \le L \le 10).

Each of the next blocks describes a cutout.

The first line of the -th block (1 \le j \le L) contains a single integer M_j – the number of vertices of the -th cutout (3 \le M_j \le 50).

The next M_j lines of the -th block provide the coordinates of the -th vertex of the cutout as two integers V_{kX} and V_{kY}, separated by a space (1 \le k \le M_j, 1 \le V_{kX} \le 99, 1 \le V_{kY} \le 99). The vertices are listed in the order they connect to form the polygon.

The last line contains two integers Z_X and Z_Y, separated by a space – the coordinates of the remaining nail (1 \le Z_X \le 99, 1 \le Z_Y \le 99).

Output

The output should be a single real number – the absolute magnitude of the frame's rotation angle (0 \le A < 180). The result should be formatted to six decimal places, using a dot as the decimal separator.

Examples

Example 1

Loading
Loading