program ex(f1,f2);
type
st=array [1..15] of integer;
zn=array [1..5000,1..15] of integer;
var
a:st; c:zn; i,j,k,m,n,n2:integer; f1,f2:text;
answer:longint; q:integer;
procedure shuchu;
var i:integer; flag:boolean;
begin
flag:=true;
for i:=1 to m-1 do
if a[i]>a[i+1] then
begin
flag:=false;
break;
end;
if flag then
begin
inc(q);
inc(answer);
for i:=1 to m do c[q,i]:=a[i];
end;
end;
procedure try(step:integer);
var i:integer;
begin
if step<m then
begin
for i:=1 to n do
begin
if n2>0 then
begin
a[step]:=i;
n2:=n2-i;
try(step+1);
n2:=n2+i;
end;
end;
end
else
begin
if step=m
then
begin
a[step]:=n2;
shuchu;
end;
end;
end;
begin
assign(f1,'dataa.in'); reset(f1);
assign(f2,'dataa.out'); rewrite(f2);
readln(f1,n,m);
answer:=0;
q:=0;
n2:=n;
for i:=1 to m do a[i]:=0;
try(1);
writeln(f2,answer);
for i:=1 to q do
begin
for j:=1 to m-1 do write(f2,c[i,j],' ');
writeln(f2,c[i,m]);
end;
close(f1);
close(f2);
end.