var N, i, j: integer;
    m: array[1..20, 1..20] of integer;
    f: text;
    Code: word;
begin
  if ParamCount < 2 then exit;
  Val(ParamStr(1), N, Code);
  randomize;
  for i := 1 to N do
    for j := i + 1 to N do begin
      m[i, j] := random(10000+1);
      m[j, i] := m[i, j];
    end;
  assign(f, ParamStr(2)); rewrite(f);
  writeln(f, N);
  for i := 1 to N do begin
    for j := 1 to N do begin
      if j > 1 then write(f, ' ');
      write(f, m[i, j]);
    end;
    writeln(f);
  end;
  close(f);
end.