{$APPTYPE CONSOLE}
type
  TS = set of 1..100;
var
  f: TextFile;
  sq: array [0..9, 0..9] of TS;
  cols: array [1..100] of TS;
  row: TS;
  N: Integer;
  ok: Boolean;

  function Check: Boolean;
  var
    i, j, v: Integer;
  begin
    Result := false;
    for i := 1 to N*N do begin
      row := [];
      for j := 1 to N*N do begin
        Read(v);
        if v = 0 then continue;
        if (v in row) or (v in cols[j]) or (v in sq[(i - 1) div N, (j - 1) div N]) then
          Exit;
        Include(row, v);
        Include(cols[j], v);
        Include(sq[(i - 1) div N, (j - 1) div N], v);
      end;
    end;
    Result := true;
  end;

begin
//  AssignFile(f, 'input.txt'); Reset(f);
  Read(N);
  ok := Check;
//  CloseFile(f);
//  AssignFile(f, 'output.txt'); Rewrite(f);
  if not ok then Write('IN');
  Writeln('CORRECT');
//  CloseFile(f);
end.
