program gmy(input,output);
var
n,m,i,j,l:longint;
a:array[1..10]of longint;
b:array[1..10000,1..10]of longint;
procedure try(k,sum:longint);
var
i,j:longint;
begin
if sum>n then exit;
if k=m+1 then begin
if sum=n then begin
l:=l+1;
for i:=1 to m do
b[l,i]:=a[i];
exit;
end
else exit;
end;
if k=1 then j:=1
else j:=a[k-1];
for i:=j to n do
begin
a[k]:=i;
try(k+1,sum+i);
a[k]:=0;
end;
end;
begin
assign(input,'dataa.in');
reset(input);
assign(output,'dataa.out');
rewrite(output);
readln(n,m);
try(1,0);
writeln(l);
for i:=1 to l do
begin
for j:=1 to m do
write(b[i,j],' ');
writeln;
end;
close(input);
close(output);
end.