var
n,m,i:integer;
sum:longint;
a:array[0..30]of integer;
s:array[0..100000]of integer;
procedure pri;
begin
inc(sum);
for i:=1 to m do
s[m*sum-m+i]:=a[i];
end;
procedure work(n,k:integer);
var i:longint;
begin
if (k=m+1)and(n=0) then begin
pri;exit;
end;
for i:=1 to n do
if i>=a[k-1] then begin
a[k]:=i;
work(n-i,k+1);
end;
end;
begin
assign(input,'dataa.in');reset(input);
assign(output,'dataa.out');rewrite(output);
readln(n,m);sum:=0;
fillchar(a,sizeof(a),0);
fillchar(s,sizeof(s),0);
work(n,1);
writeln(sum);
for i:=1 to m*sum do begin
write(s[i],' ');
if (i mod m)=0 then writeln;
end;
close(input);
close(output);
end.