{$apptype console}

uses testlib, SysUtils;

type int = longint;

const nmax = 501;

var a : array[1..nmax] of int;
    x, i, n, j : int;

function max(x, y : int) : int;
begin
    if (x < y) then max := y else max := x;
end;

begin
    x := ans.readlongint;
    if (x = -1) then begin
        if (ouf.readlongint <> -1) then quit(_wa, '');
        quit(_ok, '');
    end;
    n := inf.readlongint;
    for i := 1 to n do begin
        a[i] := ouf.readlongint;
        if (a[i] < 1) then quit(_wa, '');
    end;
    for i := 1 to n do
        for j := 1 to n do begin
            x := inf.readlongint;
            if (i <> j) then begin
                if (max(a[i], a[j]) <> x) then quit(_wa, inttostr(i) + ' ' + inttostr(j));
            end else
                if (x <> 0) then quit(_fail, 'wrong tests');
        end;
    quit(_ok, '');
end.
