import java.util.ArrayList;
import java.util.HashMap;
import java.util.TreeSet;

import ru.ifmo.testlib.*;
import ru.ifmo.testlib.Outcome.Type;

public class Check implements Checker {

	long gcd(long x, long y) {
		return x == 0 ? y : gcd(y % x, x);
	}

	class Point implements Comparable<Point> {
		long x, y;
		int id;

		public Point(long x, long y, int id) {
			super();
			long g = gcd(x, y);
			x /= g;
			y /= g;
			this.x = x;
			this.y = y;
			this.id = id;
		}

		Point middle(Point other) {
			long xx = x * other.y + other.x * y;
			long yy = y * other.y * 2;
			return new Point(xx, yy, -1);
		}

		@Override
		public int compareTo(Point o) {
			if (o.x == x)
				return Long.compare(y, o.y);
			return Long.compare(x, o.x);
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			final Point other = (Point) obj;
			if (x != other.x || y != other.y)
				return false;
			return true;
		}

	}

	@Override
	public Outcome test(InStream inf, InStream ouf, InStream ans) {
		String contestantAns = ouf.nextToken();
		String realAns = ans.nextToken();
		if (!realAns.equals(contestantAns))
			return new Outcome(Type.WA, "Participant's answer is wrong.");
		int n = inf.nextInt();

		ArrayList<Point> answ = new ArrayList<Point>();
		HashMap<String, Integer> ids = new HashMap<String, Integer>();
		TreeSet<Point> points = new TreeSet<Point>();
		ArrayList<Point> newPoints = new ArrayList<Point>();
		Point[] pointsArr = new Point[n];
		for (int i = 0; i < n; i++) {
			Point tmp = new Point(inf.nextInt(), inf.nextInt(), i + 1);
			ids.put(Long.toString(tmp.x) + "/" + Long.toString(tmp.y), i + 1);
			points.add(tmp);
			pointsArr[i] = tmp;
			if (tmp.x == 0 || tmp.x == tmp.y) {
				newPoints.add(tmp);
			}
		}
		int it = 0;
		while (it < newPoints.size()) {
			Point p = newPoints.get(it);
			if (points.contains(p))
				points.remove(p);
			for (int i = 0; i < it; i++) {
				Point midPoint = p.middle(newPoints.get(i));
				if (points.contains(midPoint)) {
					newPoints.add(midPoint);
					points.remove(midPoint);
					answ.add(midPoint);
					answ.add(p);
					answ.add(newPoints.get(i));
				}
			}
			it++;
		}
		if (points.size() != 0) {
			int pointId = ouf.nextInt();
			if (pointId < 1 || pointId > n)
				return new Outcome(Type.WA, "There is no point with such id");
			Point p = pointsArr[pointId - 1];
			if (points.contains(p)) {
				return new Outcome(Type.OK, "Ok");
			} else {
				return new Outcome(Type.WA, "Participant's answer is wrong.");
			}
		} else {
			boolean[] was = new boolean[n];
			for (int i = 0; i < n; i++)
				if (pointsArr[i].x == 0 || pointsArr[i].x == pointsArr[i].y)
					was[i] = true;
			for (int i = 0; i < n - 2; i++) {
				int newP = ouf.nextInt();
				int from1 = ouf.nextInt();
				int from2 = ouf.nextInt();
				if (newP < 1 || newP > n)
					return new Outcome(Type.WA,
							"There is no point with such id");
				if (from1 < 1 || from1 > n)
					return new Outcome(Type.WA,
							"There is no point with such id");
				if (from2 < 1 || from2 > n)
					return new Outcome(Type.WA,
							"There is no point with such id");
				if (was[newP - 1])
					return new Outcome(Type.WA,
							"Such point has already existed.");
				if (!was[from1 - 1] || !was[from2 - 1])
					return new Outcome(Type.WA,
							"Such points haven't existed yet. "
									+ pointsArr[from1 - 1].x + "/"
									+ pointsArr[from1 - 1].y + ", "
									+ pointsArr[from2 - 1].x + "/"
									+ pointsArr[from2 - 1].y + "(" + i + ")");
				Point middle = pointsArr[from1 - 1].middle(pointsArr[from2 - 1]);
				if (!middle.equals(pointsArr[newP - 1]))
					return new Outcome(Type.WA,
							"Point is not lie between others.");
				was[newP - 1] = true;
			}
		}
		return new Outcome(Type.OK, "Ok");
	}

}
