{$apptype console}

uses 
  Math, SysUtils;

{$I gens.inc}

var
  i, j, k, d: integer;
  n, m: integer;
begin
  n := StrToInt(ParamStr(1));
  m := StrToInt(ParamStr(2));
  d := Min(MAXD, n);
  
  writeln(d, ' ', n * m);
  Assert(n * m <= MAXN);

  for i := 1 to n do begin
    for j := 1 to m do begin
      write(100);
      for k := 1 to d do
        if (k < i) then 
          write(' ', 1)
        else
          write(' ', 0);
      for k := 1 to d do 
        if (k <= i) then 
          write(' ', 1)
        else
          write(' ', 0);

      writeln;
    end;
  end;
end.