import static ru.ifmo.testlib.Outcome.quit;

import java.math.BigInteger;

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


public class Check implements Checker {
	
	BigInteger TWO = BigInteger.valueOf(2);
	BigInteger THREE = BigInteger.valueOf(3);
	
	boolean check(BigInteger l, BigInteger r, BigInteger x) {
		if (x.compareTo(l) < 0) {
			return false;
		}
		if (x.compareTo(r) > 0) {
			return false;
		}
		if (x.equals(l) || x.equals(r)) {
			return true;
		}
		return check(l, TWO.multiply(l).add(r).divide(THREE), x) || check(TWO.multiply(r).add(l).divide(THREE), r, x);
	}

	@Override
	public Outcome test(InStream inf, InStream ouf, InStream ans) {
		int n = inf.nextInt();
		BigInteger k = inf.nextBigInteger();
		String s = ouf.nextToken();
		if ("Impossible".equals(s)) {
			quit(Type.WA, "Solution not found");
		}
		BigInteger a = null;
		try {
			a = new BigInteger(s);
		} catch (NumberFormatException ex) {
			quit(Type.PE, "Impossible or integer expected, " + s + " found");
		}
		BigInteger b = ouf.nextBigInteger();
		if (!b.subtract(a).equals(k)) {
			quit(Type.WA, "Wrong difference");
		}
		if (!check(BigInteger.ZERO, BigInteger.valueOf(3).pow(n), a)) {
			quit(Type.WA, "a is not written");
		}
		if (!check(BigInteger.ZERO, BigInteger.valueOf(3).pow(n), b)) {
			quit(Type.WA, "b is not written");
		}
		quit(Type.OK, "OK :)");
		return null;
	}
}
