
uses
  SysUtils;
var
  i, j, N: Integer;
begin
  N := StrToIntDef(ParamStr(1), 1);
  Writeln(N * N);
  for i := 1 to N do begin
    for j := 1 to N do 
      Write(i, ' ', j, '  ');
    Writeln;
  end;
end.
