program cogs26;
var
ans:longint;
a:array[0..11]of longint;
an:array[0..1000000]of longint;
i,n,m:longint;
procedure init;
begin
assign(input,'dataa.in');reset(input);
assign(output,'dataa.out');rewrite(output);
end;
procedure dfs(x,t:longint);
var i:longint;
begin
if (x=m+1) then
begin
if t=0 then
begin
inc(ans);
for i:=1 to m do
an[(ans-1)*m+i]:=a[i];
end;exit;
end;
for i:=a[x-1] to t do
begin
a[x]:=i;
dfs(x+1,t-i);
end;
end;
procedure main;
begin
readln(n,m);
a[0]:=1;
dfs(1,n);
writeln(ans);
for i:=1 to ans*m do
begin
if i mod m<>0 then write(an[i],' ') else
writeln(an[i]);
end;
end;
begin
init;
main;
end.