var
n,m,i,j:longint;
x,y:array[0..1000] of integer;
begin
assign(input,'compages.in');
assign(output,'compages.out');
reset(input);
rewrite(output);
read(n,m);
for i:=1 to m do begin x[i]:=x[i-1]+1; write(' ',x[i]); end;
writeln;
y[m+1]:=n+1;
for i:=m downto 1 do y[i]:=y[i+1]-1;
y[0]:=10000;
while x[0]=0 do
begin
i:=m;
while x[i]=y[i] do i:=i-1;
x[i]:=x[i]+1;
for j:=i+1 to m do x[j]:=x[j-1]+1;
if i<>0 then
begin
for j:=1 to m do write(' ',x[j]);
writeln;
end;
end;
close(input);
close(output);
end.