program dataa;
type shuzu=array[1..21]of integer;
var n,m,use,ans,i,j:integer;
sz:shuzu;
out:array[1..100,1..21]of integer;
txt:text;
procedure output;
var i,j,tem,a:integer;
boo:boolean;
begin
boo:=false;
tem:=sz[1];
a:=sz[1];
for i:=2 to m do
begin
if sz[i]<tem then boo:=true;
tem:=sz[i];
a:=a+sz[i];
end;
if (not(boo))and(a=n) then
begin
inc(ans);
for i:=1 to m do
out[ans,i]:=sz[i];
end;
end;
procedure qj(add:integer);
var i:integer;
begin
if add<=m then
for i:=1 to n-use do
begin
sz[add]:=i;
use:=use+i;
qj(add+1);
sz[add]:=0;
use:=use-i;
end else output;
end;
begin
assign(txt,'dataa.in');
reset(txt);
readln(txt,n,m);
close(txt);
qj(1);
assign(txt,'dataa.out');
rewrite(txt);
writeln(txt,ans);
for i:=1 to ans do
begin
for j:=1 to m do
write(txt,out[i,j],' ');
writeln(txt);
end;
close(txt);
end.