const
  dx : array[1..4] of integer = (-1, 0, 0, 1);
  dy : array[1..4] of integer = (0, -1, 1, 0);
  maxn = 100;
  maxk = 1000;

var
  n, m, k, i, j, b, e, x, y, xx, yy, dir : integer;
  c, qx, qy : array[0..maxn * maxn] of integer;
  tab : array[1..maxn, 1..maxn] of integer;
  u : array[1..maxn, 1..maxn] of boolean;

procedure wa;
begin
  writeln('Wrong answer');
  halt;
end;

begin
  reset(input, 'glue.in');
  rewrite(output, 'glue.out');
  read(n, m, k);
  assert((1 <= n) and (n <= maxn));
  assert((1 <= m) and (m <= maxn));
  assert((1 <= k) and (k <= maxk));
  assert(((n * m) mod k) = 0);
  for i := 1 to n do begin
    for j := 1 to m do begin
      read(tab[i][j]);
      assert((1 <= tab[i][j]) and (tab[i][j] <= n * m div k));
    end;
  end;
  for i := 1 to n do begin
    for j := 1 to m do begin
      if not(u[i][j]) then begin
        if (c[tab[i][j]] <> 0) then begin
          wa;
        end;
        qx[0] := i;
        qy[0] := j;
        b := 0;
        e := 1;
        u[i][j] := true;
        inc(c[tab[i][j]]);
        while (b <> e) do begin
          x := qx[b];
          y := qy[b];
          b := b + 1;
          for dir := 1 to 4 do begin
            xx := x + dx[dir];
            yy := y + dy[dir];
            if (xx > 0) and (xx <= n) and (yy > 0) and (yy <= m) and (tab[xx][yy] = tab[x][y]) and (not(u[xx][yy])) then begin
              qx[e] := xx;
              qy[e] := yy;
              e := e + 1;
              u[xx][yy] := true;
              inc(c[tab[xx][yy]]);
            end;
          end;
        end;
      end;
    end;
  end;
  for i := 1 to n*m div k do begin
    if (c[i] <> k) then begin
      wa;
    end;
  end;
  writeln('OK');
end.