import ru.ifmo.testlib.InStream;
import ru.ifmo.testlib.Outcome;
import ru.ifmo.testlib.Outcome.Type;
import static ru.ifmo.testlib.Outcome.Type.*;
import java.util.*;

public class Check implements ru.ifmo.testlib.Checker {

    @Override
    public Outcome test(InStream inf, InStream ouf, InStream ans) {
        String pa = ouf.nextToken();
        String ja = ans.nextToken();
        String sn = inf.nextToken();
        long m = inf.nextLong();

        //cerr << pa << " " << ja << " " << sn << endl;

        boolean flag = false;
        if (Objects.equals(ja, "-1")) {
            if (Objects.equals(pa, "-1")) {
                return new Outcome(OK, "answer doesn't exist");
            }
            flag = true;
        }

        if (Objects.equals(pa, "-1")) {
            return new Outcome(WA, "participant think that answer doesn't exist, but it exist");
        }

        if (pa.length() != sn.length()) {
            return new Outcome(WA, "length of participant's answer isn't equal to length of n");
        }

        if (pa.length() > 1 && pa.charAt(0) == '0') {
            return new Outcome(WA, "participant's answer start with 0 and isn't equal to 0");
        }

        long pn;
        try {
            pn = Long.parseLong(pa);
        } catch (NumberFormatException e) {
            return new Outcome(WA, "integer expected, " + pa + " found");
        }
        if (pn < 0) {
            return new Outcome(WA, "negative number");
        }

        if (pn % m != 0) {
            return new Outcome(WA, "participant's answer isn't divisible by m");
        }

        if (flag) {
            return new Outcome(FAIL, "jury think that answer doesn't exist, but participant found it");
        }

        int balp = 0, balj = 0;

        for (int i = 0; i < sn.length(); ++i) {
            if (pa.charAt(i) != sn.charAt(i)) {
                ++balp;
            }
            if (ja.charAt(i) != sn.charAt(i)) {
                ++balj;
            }
        }

        if (balp > balj) {
            return new Outcome(WA, "jury's answer is better than participant's");
        }

        if (balp < balj) {
            return new Outcome(FAIL, "jury's answer is worse than participant's");
        }

        return new Outcome(OK, "answer is correct");
    }
}
