uses
  SysUtils;
var
  i, j, N, v: Integer;
begin
  N := StrToIntDef(ParamStr(1), 1);
  v := StrToIntDef(ParamStr(2), 4);
  RandSeed := StrToIntDef(ParamStr(3), 1);
  Writeln(N);
  for i := 1 to N do begin
    for j := 1 to N do
      Write(Random(v), ' ');
    Writeln;
  end;
end.
