/*
 * Copyright (c) 2006 Kamo Hiroyasu
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

/*
 *  An answer to ACM/ICPC Domestic Contest 2005 Problem B
 *	Polygonal Line Search
 *
 *  Author: Kamo Hiroyasu <wd@ics.nara-wu.ac.jp>
 */

#include <stdio.h>
#include <stdlib.h>

#ifndef MAXNSEG
#define MAXNSEG	10
#endif

struct point {
	int	x, y;
};

int	main_loop(FILE *);
void	normalize(int, struct point*);

static void
polygon_copy(struct point *q, const struct point *p, int n)
{
	int	i;

	for (i = 0; i < n; i ++) {
		q[i] = p[i];
	}
}

static void
polygon_reverse_copy(struct point *q, const struct point *p, int n)
{
	int	i;

	for (i = 0; i < n; i ++) {
		q[i] = p[n - i - 1];
	}
}

static int
polygon_equal(const struct point *p1, const struct point *p2, int n)
{
	int	i;

	for (i = 0; i < n; i ++) {
		if (p1[i].x != p2[i].x || p1[i].y != p2[i].y)
			return 0;
	}
	return 1;
}

static inline int
polygon_equiv_aux(const struct point *p1, const struct point *p2, int n,
		  void (*copy)(struct point *, const struct point *, int))
{
	struct point	q2[n];

	(*copy)(q2, p2, n);
	normalize(n, q2);
	return polygon_equal(p1, q2, n);
}

static int
polygon_equiv(int n1, const struct point *p1, int n2, const struct point *p2)
{
	return n1 == n2 &&
		(polygon_equiv_aux(p1, p2, n1, polygon_copy) ||
		 polygon_equiv_aux(p1, p2, n1, polygon_reverse_copy));
}

static void
rotate0(struct point *p, int x0, int y0)
{
	p->x -= x0;
	p->y -= y0;
}

static void
rotate270(struct point *p, int x0, int y0)
{
	int	x = p->y - y0;
	int	y = x0 - p->x;
	p->x = x;
	p->y = y;
}

static void
rotate180(struct point *p, int x0, int y0)
{
	p->x = x0 - p->x;
	p->y = y0 - p->y;
}

static void
rotate90(struct point *p, int x0, int y0)
{
	int	x = y0 - p->y;
	int	y = p->x - x0;
	p->x = x;
	p->y = y;
}

void
normalize(int n, struct point *p)
{
	int	x0, y0, x1, y1;
	int	i;
	void	(*trans)(struct point *, int, int) = NULL;

	x0 = p[0].x;
	y0 = p[0].y;
	x1 = p[1].x;
	y1 = p[1].y;
	if (x1 > x0 && y1 == y0) {
		trans = rotate0;
	} else if (x1 == x0 && y1 > y0) {
		trans = rotate270;
	} else if (x1 < x0 && y1 == y0) {
		trans = rotate180;
	} else if (x1 == x0 && y1 < y0) {
		trans = rotate90;
	}
	for (i = 0; i < n; i ++) {
		(*trans)(&p[i], x0, y0);
	}
}

int
polygon_read(FILE *fp, struct point *p)
{
	int	i;
	int	n;

	if (fscanf(fp, "%d", &n) != 1 || n < 0 || n > MAXNSEG) {
		return -1;
	}
	for (i = 0; i < n; i ++) {
		if (fscanf(fp, "%d%d", &p[i].x, &p[i].y) != 2) {
			return -1;
		}
	}
	return n;
}

int
main_loop(FILE *fp)
{
	int		i;
	int		n;
	int		n0, ni;
	struct point	p0[MAXNSEG], pi[MAXNSEG];

	while (scanf("%d", &n) == 1 && n > 0) {
		n0 = polygon_read(stdin, p0);
		normalize(n0, p0);
		for (i = 1; i <= n; i ++) {
			ni = polygon_read(stdin, pi);
			if (polygon_equiv(n0, p0, ni, pi)) {
				printf("%d\n", i);
			}
		}
		printf("+++++\n");
	}
	return 0;
}

int
main(int argc, char *argv[])
{
	main_loop(stdin);
	return 0;
}
