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

import java.math.BigInteger;

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));
    }

    final int MAXN = 100;

    public Outcome test(InStream inf, InStream ouf, InStream ans) {
        long need = inf.nextLong();
        
        int n = ouf.nextInt();
        if (0 >= n || n > MAXN) {
            return outcome(WA, "Wrong n in output");
        }
        
        int[] a = new int[n];
        BigInteger answer = BigInteger.ZERO;
        for (int i = 0; i < n; i++) {
            a[i] = ouf.nextInt();
            if (a[i] != 0 && a[i] != 1) {
                return outcome(WA, "Number in output is not equal to 0 nor 1");
            }
            if (n > 1 && i == n - 1 && a[i] == 0) {
                return outcome(WA, "Leading zero");
            }
            BigInteger x = BigInteger.valueOf(a[i]).multiply(BigInteger.ONE.shiftLeft(i));
            if (i % 2 == 1)
                x = x.negate();
            answer = answer.add(x);
        }

        if (answer.compareTo(BigInteger.valueOf(need)) != 0) {
            return outcome(WA, "The number derived from the sequence is not equal to the number in input");
        }

        return outcome(OK, "x = " + need);
    }
}
