(*--------------------------------------------------------------*)
(* ACM ICPC 2009-2010, NEERC                                    *)
(* Northern Subregional Contest                                 *)
(* St Petersburg, October 17, 2009                              *)
(*--------------------------------------------------------------*)
(* Problem D. Dragon's Question                                 *)
(*                                                              *)
(* Original idea         Georgiy Korneev                        *)
(* Problem statement     Dmitry Shtukenberg                     *)
(* Testset               Georgiy Korneev                        *)
(*--------------------------------------------------------------*)
(* Checker                                                      *)
(*                                                              *)
(* Author                gk                                     *)
(*--------------------------------------------------------------*)
 
{$R+,S+}

uses
  testlib, sysutils;

function check(d: longint; a: string): boolean;
var
    i: longint;
    r: longint;
begin
    r := 0;
    for i := 1 to length(a) do begin
        r := (r * 10 + ord(a[i]) - ord('0')) mod d;
    end;
    check := r = 0;
end;

var 
    i: longint;
    n, d: longint;
    ja: string;
    pa: string;
begin
    n := inf.readLongint();
    d := inf.readLongint();
    ja := trim(ans.readString());
    pa := trim(ouf.readString());

    if (pa = 'No solution') then begin
        if (ja = 'No solution') then begin
            quit(_ok, 'No solution');
        end else begin
            quit(_wa, 'Solution exists, but not found');
        end;
    end;

    if (length(pa) <> n) then begin
        quit(_wa, format('Invalid length %d instead of %d', [length(pa), n]));
    end;

    for i := 1 to length(pa) do begin
        if (not (pa[i] in ['0'..'9'])) then begin
            quit(_wa, format('Not a digit "%s" at %d', [pa[i], i]));
        end;
    end;

    if (pa[1] = '0') then begin
        quit(_wa, 'Leading zero');
    end;

    if (not check(d, pa)) then begin
        quit(_wa, 'Not divisible');
    end;

    if (ja = 'No solution') then begin
        quit(_fail, 'Solution missed by the jury');
    end;

    quit(_OK, '');
end.
