var m,n,t,k,x,q:longint;
a:array[1..10]of longint;
b:array[1..1000]of longint;
function temp:longint;
var z:longint;begin
temp:=0;
for z:=1 to m do
temp:=temp+a[z];
end;
procedure dfs(step,p:longint);
var i,c:longint;
begin
if step>m then begin
if (temp=n) then
begin
inc(t);
for c:=1 to m do
begin
b[c+k]:=a[c];
end;
k:=k+m;
end;
exit;
end;
for i:=1 to p do
if i>=a[step-1] then
begin
a[step]:=i;
dfs(step+1,p-a[step]);
end;
end;
begin
assign(input,'dataa.in');
assign(output,'dataa.out');
reset(input);
rewrite(output);
k:=0;
readln(n,m);
dfs(1,n);
writeln(t);
q:=1;
while q+2<>k do
begin
for x:=q to q+m-1 do
write(b[x],' ');
writeln;
q:=q+m;
end;
for x:=k-2 to k do
write(b[x],' ');
close(input);
close(output);
end.