#include "bits/stdc++.h"
using namespace std;

//#define int int64_t

//#define CHOOSE(a) CHOOSE2 a
//#define CHOOSE2(a0,a1,a2,a3,x,...) x
//#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
//#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
//#define REP3(i, n) REP2(i, 0, n)
//#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)

#define rep(i, n) for(int i = 0; i < n; i++)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

//using VV = vector<vector<int>>;
//using V = vector<int>;
//using P = pair<int, int>;
//using IP = pair<int, P>;

typedef complex<double> P;
typedef vector<P> L;
namespace std {
	bool operator < (const P& a, const P& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
bool operator == (const L& a, const L& b) {
	if (a.size() != b.size()) return false;
	rep(i, a.size()) if (a[i] != b[i]) return false;
	return true;
}
P rs[] = { P(1, 0), P(0, 1), P(-1, 0), P(0, -1) };
L rotate(L line, int idx) {
	L ret = line;
	for (auto& x : ret) {
		x *= rs[idx];
	}
	return ret;
};
L move(L line) {
	P sub = *min_element(all(line));
	L ret = line;
	for (auto& x : ret) {
		x -= sub;
	}
	return ret;
};
L input() {
	int m; cin >> m;
	L l(m);
	rep(i, m) {
		int x, y; cin >> x >> y;
		l[i] = P(y, x);
	}
	return l;
};
bool equal(L l1, L l2) {
	L l22 = l2;
	reverse(all(l22));
	rep(i, 4) {
		if (move(l1) == move(rotate(l2, i)) || move(l1) == move(rotate(l22, i))) return true;
	}
	return false;
};

signed main() {
	int n;
	while (cin >> n && n) {
		vector<L> lines(n - 1);
		L line;

		line = input();
		stringstream ss;
		rep(i, n) {
			if (equal(line, input())) {
				ss << i + 1 << endl;
			}
		}
		ss << "+++++" << endl;
		cout << ss.str();
	}
}
### Prompt

Your challenge is to write a cpp solution to the following problem:

Multiple polygonal lines are given on the xy-plane. Given a list of polygonal lines and a template, you must find out polygonal lines which have the same shape as the template.

A polygonal line consists of several line segments parallel to x-axis or y-axis. It is defined by a list of xy-coordinates of vertices from the start-point to the end-point in order, and always turns 90 degrees at each vertex. A single polygonal line does not pass the same point twice. Two polygonal lines have the same shape when they fully overlap each other only with rotation and translation within xy-plane (i.e. without magnification or a flip). The vertices given in reverse order from the start-point to the end-point is the same as that given in order.

Figure 1 shows examples of polygonal lines. In this figure, polygonal lines A and B have the same shape.

Write a program that answers polygonal lines which have the same shape as the template.

<image>
---
Figure 1: Polygonal lines



Input

The input consists of multiple datasets. The end of the input is indicated by a line which contains a zero.

A dataset is given as follows.

> n
>  Polygonal line0
>  Polygonal line1
>  Polygonal line2
>  ...
>  Polygonal linen

n is the number of polygonal lines for the object of search on xy-plane. n is an integer, and 1 <= n <= 50. Polygonal line0 indicates the template.

A polygonal line is given as follows.

> m
>  x1 y1
>  x2 y2
>  ...
>  xm ym
>

m is the number of the vertices of a polygonal line (3 <= m <= 10). xi and yi, separated by a space, are the x- and y-coordinates of a vertex, respectively (-10000 < xi < 10000, -10000 <yi < 10000).

Output

For each dataset in the input, your program should report numbers assigned to the polygonal lines that have the same shape as the template, in ascending order. Each number must be written in a separate line without any other characters such as leading or trailing spaces.

Five continuous "+"s must be placed in a line at the end of each dataset.

Example

Input

5
5
0 0
2 0
2 1
4 1
4 0
5
0 0
0 2
-1 2
-1 4
0 4
5
0 0
0 1
-2 1
-2 2
0 2
5
0 0
0 -1
2 -1
2 0
4 0
5
0 0
2 0
2 -1
4 -1
4 0
5
0 0
2 0
2 1
4 1
4 0
4
4
-60 -75
-60 -78
-42 -78
-42 -6
4
10 3
10 7
-4 7
-4 40
4
-74 66
-74 63
-92 63
-92 135
4
-12 22
-12 25
-30 25
-30 -47
4
12 -22
12 -25
30 -25
30 47
3
5
-8 5
-8 2
0 2
0 4
8 4
5
-3 -1
0 -1
0 7
-2 7
-2 16
5
-1 6
-1 3
7 3
7 5
16 5
5
0 1
0 -2
8 -2
8 0
17 0
0


Output

1
3
5
+++++
3
4
+++++
+++++

### Response

```cpp
#include "bits/stdc++.h"
using namespace std;

//#define int int64_t

//#define CHOOSE(a) CHOOSE2 a
//#define CHOOSE2(a0,a1,a2,a3,x,...) x
//#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
//#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
//#define REP3(i, n) REP2(i, 0, n)
//#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)

#define rep(i, n) for(int i = 0; i < n; i++)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

//using VV = vector<vector<int>>;
//using V = vector<int>;
//using P = pair<int, int>;
//using IP = pair<int, P>;

typedef complex<double> P;
typedef vector<P> L;
namespace std {
	bool operator < (const P& a, const P& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
bool operator == (const L& a, const L& b) {
	if (a.size() != b.size()) return false;
	rep(i, a.size()) if (a[i] != b[i]) return false;
	return true;
}
P rs[] = { P(1, 0), P(0, 1), P(-1, 0), P(0, -1) };
L rotate(L line, int idx) {
	L ret = line;
	for (auto& x : ret) {
		x *= rs[idx];
	}
	return ret;
};
L move(L line) {
	P sub = *min_element(all(line));
	L ret = line;
	for (auto& x : ret) {
		x -= sub;
	}
	return ret;
};
L input() {
	int m; cin >> m;
	L l(m);
	rep(i, m) {
		int x, y; cin >> x >> y;
		l[i] = P(y, x);
	}
	return l;
};
bool equal(L l1, L l2) {
	L l22 = l2;
	reverse(all(l22));
	rep(i, 4) {
		if (move(l1) == move(rotate(l2, i)) || move(l1) == move(rotate(l22, i))) return true;
	}
	return false;
};

signed main() {
	int n;
	while (cin >> n && n) {
		vector<L> lines(n - 1);
		L line;

		line = input();
		stringstream ss;
		rep(i, n) {
			if (equal(line, input())) {
				ss << i + 1 << endl;
			}
		}
		ss << "+++++" << endl;
		cout << ss.str();
	}
}
```