import ru.ifmo.testlib.Checker;
import ru.ifmo.testlib.InStream;
import ru.ifmo.testlib.Outcome;

import java.util.Locale;

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

public class Check implements Checker {
    public static final double EPS2 = 1e-5;
    public static final double EPS = 2e-5;

    class Point {
        double x, y;

        Point(double x, double y) {
            this.x = x;
            this.y = y;
        }
    }

    public Outcome test(InStream inf, InStream ouf, InStream ans) {
        int n = inf.nextInt();
        Point[] points = new Point[n];
        for (int i = 0; i < points.length; i++) {
            points[i] = new Point(inf.nextInt(), inf.nextInt());
        }

        double jarea = readAnswer(ans, points, FAIL);
        double parea = readAnswer(ouf, points, WA);
        if (parea < jarea - EPS2 && parea < jarea * (1 - EPS2)) {
            throw new Outcome(WA, String.format(Locale.US, "Expected area %.10f, found %.10f, relative delta to jury = %.10f", jarea, parea, (parea - jarea) / jarea));
        }
        if (parea > jarea + EPS2 && parea > jarea * (1 + EPS2)) {
            throw new Outcome(FAIL, String.format(Locale.US, "Expected area %.10f, found %.10f, relative delta to jury = %.10f", jarea, parea, (parea - jarea) / jarea));
        }
        throw new Outcome(OK, String.format(Locale.US, "%.10f, relative delta to jury = %.10f", parea, (parea - jarea) / jarea));
    }

    private double readAnswer(InStream ouf, Point[] points, Outcome.Type outcome) {
        double minx = ouf.nextDouble();
        double miny = ouf.nextDouble();
        double maxx = ouf.nextDouble();
        double maxy = ouf.nextDouble();
        if (minx >= maxx + EPS) {
            throw new Outcome(outcome, String.format(Locale.US, "minx > maxx: %.10f %.10f", minx, maxx));
        }
        if (miny >= maxy + EPS) {
            throw new Outcome(outcome, String.format(Locale.US, "miny > maxy: %.10f %.10f", miny, maxy));
        }
        if (!ouf.seekEoF())
            throw new Outcome(outcome, "Extra data in file");
        inside(minx, miny, points, outcome);
        inside(maxx, miny, points, outcome);
        inside(minx, maxy, points, outcome);
        inside(maxx, maxy, points, outcome);
        return (maxx - minx) * (maxy - miny);
    }

    private void inside(double x, double y, Point[] points, Outcome.Type outcome) {
        for (int i = 0; i < points.length; i++) {
            Point p0 = points[i];
            Point p1 = points[(i + 1) % points.length];
            double dx0 = p0.x - x;
            double dy0 = p0.y - y;
            double dx1 = p1.x - x;
            double dy1 = p1.y - y;
            double a = p1.y - p0.y;
            double b = p0.x - p1.x;
            double c = a * p0.x + b * p0.y;
//            double d = Math.sqrt(a * a + b * b);
//            assert a * x + b * y - c > -EPS;
            double d = (a * x + b * y - c) / Math.sqrt(a * a + b * b);
//            assert d > -EPS;
            if (d < -EPS) {
                throw new Outcome(outcome, String.format("Point (%.10f, %.10f) is outside of the polygon by %.10f", x, y, d));
            }
        }
    }
}
