Several polygonal lines are given on the xy-plane. Given a list of polygonal lines together with one template, determine which of the polygonal lines have the same shape as the template.
A polygonal line is made of straight segments that are each parallel to the x-axis or the y-axis. It is described by the coordinates of its vertices listed in order from the start point to the end point, and it turns exactly 90 degrees at every intermediate vertex. A single polygonal line never passes through the same point twice.
Two polygonal lines have the same shape when one can be made to coincide exactly with the other using only rotation and translation in the plane (no scaling and no reflection/flip). Listing a polygonal line's vertices in reverse order — from the end point back to the start point — describes the same polygonal line, so a line and its reversal are considered identical.
Write a program that reports which polygonal lines have the same shape as the template.
The input consists of several datasets. A line containing a single 0 marks the end of the input.
Each dataset has the following format:
n
Polygonal line 0
Polygonal line 1
Polygonal line 2
...
Polygonal line n
$n$ is the number of polygonal lines to search through, an integer with $1 \le n \le 50$. Polygonal line 0 is the template; the remaining lines are numbered $1$ through $n$.
Each polygonal line is given as:
m
x1 y1
x2 y2
...
xm ym
$m$ is the number of vertices of the polygonal line ($3 \le m \le 10$). $x_i$ and $y_i$, separated by a space, are the x- and y-coordinates of the $i$-th vertex ($-10000 < x_i < 10000$, $-10000 < y_i < 10000$).
For each dataset, print the numbers of the polygonal lines (from $1$ to $n$) that have the same shape as the template, one per line in ascending order, with no leading or trailing spaces.
After the numbers for each dataset, print a line containing exactly five + characters (+++++).