Earthquake Emendations#304

Earthquake Emendations

0.1 seconds
64 megabytes
Easy

A major earthquake has turned a beautiful stained glass window at the Farm Hill College chapel into shards of glass lying on the floor. The chapel manager asks for your help to quickly restore the window. Fortunately, the window only broke along its lead joints and every individual colored piece remains intact. Additionally, all of the pieces landed on the floor either in their original orientation or rotated by a multiple of degrees ( radians); no piece has been flipped face down. After extensive searching, a schematic of the original stained glass window as it stood before the earthquake was found in the library. From the schematic, you learn that no two colored pieces of the window are identical in shape and size. With the schematic in hand, your task is to write a program that will identify the scattered shards to help reassemble the window.

Input

The input contains several test cases, each describing a broken window for you to reassemble. Each test case begins with a single integer (1 \leq n \leq 20), the number of individual glass pieces in the window. The next lines each contain the description of a unique colored glass piece as a simple polygon with nonzero area. The coordinates of the (3 \leq k \leq 100) vertices of each polygon are given in counter-clockwise order in the following format:

x_1 y_1 x_2 y_2 ... x_k y_k x_1 y_1

You may assume that the vertices of each polygon are distinct, i.e., (x_i, y_i) \neq (x_j, y_j) whenever i \neq j, and consecutive vertices are not collinear. All coordinates are integers in the range 0 \leq x_i, y_i \leq 100. The final line of each test case gives the schematic of the original window, written as a concatenation of non-overlapping polygons in the same format as above. Each polygon in the schematic corresponds to some rotation (by a multiple of degrees) plus translation of one of the glass pieces described above. Test cases are separated by blank lines, and the end of the input is marked by a single integer on a line by itself.

Output

For each test case, output a single line. For every glass piece in the input of a test case, print a single integer indicating the position in the schematic where the piece appears. Separate the numbers in the output with a single space.

Examples

Example 1

Loading
Loading