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

public class Check implements Checker {
    public Outcome outcome(Outcome.Type type, final String format, final Object... args) {
        return new Outcome(type, String.format(format, args));
    }

    public Outcome test(InStream inf, InStream ouf, InStream ans) {
        long inx = inf.nextLong();
        long iny = inf.nextLong();
        long bestx = ans.nextLong();
        long besty = ans.nextLong();
        long x = ouf.nextLong();
        long y = ouf.nextLong();
        
        if (x < 0 || y < 0) {
          return outcome(WA, "Negative numbers found in the output: %d %d", x, y);
        }

        if (gcd(x, y) != gcd(inx, iny)) {
            return outcome(WA, "GCD of participant's numbers %d %d is not equal to GCD of the input numbers %d %d", x, y, inx, iny);
        }
        if (lcm(x, y) != lcm(inx, iny)) {
            return outcome(WA, "LCM of participant's numbers %d %d is not equal to LCM of the input numbers %d %d", x, y, inx, iny);
        }
        if (x > y) {
            return outcome(WA, "x > y");
        }

        if (besty - bestx > y - x) {
            return outcome(FAIL, "Participant found better answer");
        }
        if (besty - bestx < y - x) {
            return outcome(WA, "Jury has better answer");
        }

        return outcome(OK, "Correct answer");
    }

    public long gcd(long a, long b) {
        while (b > 0) {
            a %= b;
            long tmp = a;
            a = b;
            b = tmp;
        }
        return a;
    }

    public long lcm(long a, long b) {
        return a / gcd(a, b) * b;
    }
}
