import java.util.*;

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

public class Check implements Checker {

	final static double EPS = 1e-6;
	final static double EPS2 = 1e-10;
	final static double BOUND = 2e9;

	static boolean equal(double a, double b) {
		if (Math.abs(a - b) < EPS || Math.abs(a - b) < Math.max(a, b) * EPS2)
//		if (Math.abs(a - b) < EPS)
			return true;
		return false;
	}

	static class Point {
		double x, y;

		public Point(double x, double y) {
			if (x < -BOUND || x > BOUND || y < -BOUND || y > BOUND) {
				throw new Outcome(Type.WA, "(" + x + ", " + y + ") is bad point");
			}
			this.x = x;
			this.y = y;
		}

		public boolean equals(Point p) {
			return equal(x, p.x) && equal(y, p.y);
		}

		double distTo(Point p) {
			return Math.sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y));
		}

		@Override
		public String toString() {
			return String.format("%.10f %.10f", x, y);
		}
	}

	static class Segment {
		Point[] p;

		public Segment(Point a, Point b) {
			p = new Point[] { a, b };
		}
		
		public Segment(InStream in) {
			p = new Point[] { new Point(in.nextDouble(), in.nextDouble()), new Point(in.nextDouble(), in.nextDouble())};
		}
		
		boolean equals(Segment s) {
			return (p[0].equals(s.p[0]) && p[1].equals(s.p[1]))
					|| (p[1].equals(s.p[0]) && p[0].equals(s.p[1]));
		}

		double length() {
			return p[0].distTo(p[1]);
		}

		@Override
		public String toString() {
			return p[0] + " " + p[1];
		}
	}

	
	
    @Override
    public Outcome test(InStream inf, InStream ouf, InStream ans) {
    	Segment start = new Segment(inf);
    	Segment finish = new Segment(inf);
    	int lenghtOfAnswer = 0;
    	double len = start.length();
    	if (Math.abs(start.length() - finish.length()) > EPS) {
    		return new Outcome(Type.FAIL, "Lenghts of segments in input are not same");
    	}
    	while (!ans.seekEoF()) {
    		new Segment(ans);
    		lenghtOfAnswer++;
    	}
    	Segment s = new Segment(ouf);
    	Segment old = null;
    	if (!s.equals(finish)) {
    		return new Outcome(Type.WA, "First segment of output is not second input's segment");
    	}
    	int steps = 1;
    	outer : while (!ouf.seekEoF()) {
    		old = s;
    		s = new Segment(ouf);
    		steps++;
    		if (s.equals(start) || steps == lenghtOfAnswer) {
    			break;
    		}
    		if (!equal(s.length(), len)) {
    			return new Outcome(Type.WA, "Wrong segment length");
    		}
    		for (int i = 0; i < 2; i++) {
    			for (int j = 0; j < 2; j++) {
    				if (old.p[i].equals(s.p[j])) {
    					continue outer;
    				}
    			}
    		}
    		return new Outcome(Type.WA, "Wrong step #" + steps);
    	}

	boolean good = false;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			if (old == null || old.p[i].equals(s.p[j])) {
				good = true;
			}
		}
	}

	if (!good)
		return new Outcome(Type.WA, "Wrong step #" + steps);
    	
//    	if (!ouf.seekEoF()) {
//    		return new Outcome(Type.WA, "Extra data in output or non-optimal answer");
//    	}
    	
		if (steps < lenghtOfAnswer && s.equals(start)) {
			return new Outcome(Type.FAIL, "Contestant found better solution :( " + steps + ", instead of " + lenghtOfAnswer);
		} else if (s.equals(start)) {
			return new Outcome(Type.OK, "OK"); 
		} else {
			return new Outcome(Type.WA, "Last segment is not first input's segment");
		}
    }
}
