/******************************************************************/
/* ACM ICPC 2012-2013                                             */
/* Northeastern European Regional Contest                         */
/* St Petersburg - Barnaul - Tashkent - Tbilisi, December 2, 2012 */
/******************************************************************/
/* Problem K. Kingdom Reunion                                     */
/*                                                                */
/* Original idea         Maxim Buzdalov                           */
/* Problem statement     Maxim Buzdalov                           */
/* Test set              Maxim Buzdalov                           */
/******************************************************************/
/* Checker                                                        */
/*                                                                */
/* Author                Maxim Buzdalov                           */
/******************************************************************/

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

import java.util.Arrays;
import java.util.List;

import static ru.ifmo.testlib.Outcome.Type.OK;
import static ru.ifmo.testlib.Outcome.Type.PE;
import static ru.ifmo.testlib.Outcome.Type.WA;

public class Check implements Checker {
    public static final String A = "Aastria";
    public static final String B = "Abstria";
    public static final String C = "Aabstria";
    public static final String ERR = " is not a polygon";

    public static final List<String> ANSWERS = Arrays.asList(
            A + ERR, B + ERR, C + ERR,
            A + " and " + B + " intersect",
            "The union of " + A + " and " + B + " is not equal to " + C,
            "OK"
    );

    public Outcome test(InStream inf, InStream ouf, InStream ans) {
        String ja = ans.nextLine();
        String pa = ouf.nextLine();

        if (!ANSWERS.contains(pa))
            return new Outcome(PE, String.format("Unexpected string '%s'", pa));
        if (!ouf.seekEoF())
            throw new Outcome(PE, String.format("Extra data in output file"));

        if (!ja.equals(pa)) {
            return new Outcome(WA, String.format("Expected '%s', found '%s'", ja, pa));
        }
        return new Outcome(OK, String.format("'%s'", ja));
    }
}

