program dataa;
var i,n,m,bit,ansuu:longint;
a:array[1..500]of longint;
ans:array[1..500,1..500]of longint;
f1:text;
function add:longint;
var i,n:longint;
begin
n:=0;
for i:=1 to m-1 do
n:=n+a[i];
add:=n;
end;
procedure fp(bit,min:longint);
var i:longint;
begin
if bit<m then
for i:=min to n div 2 do
begin
a[bit]:=i;
fp(bit+1,i);
a[bit]:=0;
end else
begin
a[bit]:=n-add;
if a[bit]>=min then
begin
inc(ansuu);
for i:=1 to m do
ans[ansuu,i]:=a[i];
end;
a[bit]:=0;
end;
end;
procedure output;
var i,j:longint;
f2:text;
begin
assign(f2,'dataa.out');
rewrite(f2);
writeln(f2,ansuu);
for i:=1 to ansuu do
begin
for j:=1 to m do
write(f2,ans[i,j],' ');
writeln(f2);
end;
close(f2);
end;
begin
assign(f1,'dataa.in');
reset(f1);
readln(f1,n,m);
close(f1);
fp(1,1);
output;
end.