import static ru.ifmo.testlib.Outcome.quit;
import ru.ifmo.testlib.Checker;
import ru.ifmo.testlib.InStream;
import ru.ifmo.testlib.Outcome;
import ru.ifmo.testlib.Outcome.Type;

import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.LineSegment;
import com.vividsolutions.jts.geom.Polygon;

public class Check implements Checker {

	Polygon loadPolygon(InStream stream) {
		int n = stream.nextInt();
		if (n > 1000) {
			quit(Type.WA, "too many vertex");
		}
		Coordinate[] coords = new Coordinate[n + 1];
		for (int i = 0; i < n; i++) {
			coords[i] = new Coordinate(stream.nextDouble(), stream.nextDouble());
		}
		coords[n] = coords[0];
		GeometryFactory factory = new GeometryFactory();
		Polygon polygon = factory.createPolygon(factory.createLinearRing(coords), null);
		return polygon;
	}

	double EPS = 1e-6;

	@Override
	public Outcome test(InStream inf, InStream ouf, InStream ans) {
		int n = inf.nextInt();
		Polygon source = loadPolygon(inf);
		Polygon[] p = new Polygon[n];
		for (int i = 0; i < p.length; i++) {
			p[i] = loadPolygon(ouf);
		}
		double area = source.getArea() / n;
		for (int i = 0; i < p.length; i++) {
			if (p[i].getNumPoints() > 1001) { // realy 1001!
				quit(Type.WA, "To many points in %d-th polygon", (i + 1));
			}
			Coordinate[] c = p[i].getCoordinates();
			for (int x = 0; x < c.length - 1; x++) {
				for (int y = x + 2; y < c.length - 1; y++) {
					if (x == 0 && y == c.length - 2)
						continue;
					LineSegment s1 = new LineSegment(c[x], c[x + 1]);
					LineSegment s2 = new LineSegment(c[y], c[y + 1]);
					if (s1.intersection(s2) != null) {
						quit(Type.WA, "%d-th polygon self intersect: " + s1 + " " + s2, (i + 1));
					}
				}
			}
			if (Math.abs(p[i].getArea() - area) > EPS) {
				quit(Type.WA, "Area of %d-th polygon %.6f, expected %.6f", (i + 1), p[i].getArea(), area);
			}
			for (Coordinate cp : p[i].getCoordinates()) {
				if (!source.buffer(EPS).contains(new GeometryFactory().createPoint(cp))) {
					quit(Type.WA, "%d-th polygon out of source polygon: point %s out of source", (i + 1), cp.toString());
				}
			}
			// if (Math.abs(p[i].difference(source).getArea()) > EPS) {
			// System.out.println("cur :" + p[i]);
			// System.out.println("all :" + source);
			// System.out.println("difference :" + p[i].difference(source));
			// }
		}
		for (int i = 0; i < p.length; i++) {
			for (int j = i + 1; j < p.length; j++) {
				if (Math.abs(p[i].intersection(p[j]).getArea()) > EPS) {
					quit(Type.WA, "%d-th and %d-th polygons are crossing", i + 1, j + 1);
				}
			}
		}
		quit(Type.OK, ":)");
		return null;
	}
}
