var
n,m,i,ans,l:longint;
p:array[1..11] of integer;
pr:array[1..10000,1..10] of integer;
procedure mem;
var
k:longint;
begin
for k:=1 to m do
pr[ans,k]:=p[k];
end;
procedure test(a,b,c:longint);
var
j:longint;
begin
if (c=m) and (b<>0) then exit;
if (c=m) and (b=0) then
begin
inc(ans);
mem;
exit;
end;
for j:=a to b do
begin
p[c+1]:=j;
test(j,b-j,c+1);
end;
end;
begin
assign(input,'dataa.in');
assign(output,'dataa.out');
reset(input);rewrite(output);
read(n,m);
for i:=1 to n-m+1 do
begin
p[1]:=i;
test(i,n-i,1);
end;
writeln(ans);
for i:=1 to ans do
begin
for l:=1 to m-1 do write(pr[i,l],' ');
writeln(pr[i,m]);
end;
close(input);
close(output);
end.