var
a,b,r,n:longint;
f:array[-1..1000]of longint;
begin
assign(input,'compages.in');
assign(output,'compages.out');
reset(input);
rewrite(output);
read(n,r);
for a:=r downto 1 do
f[a]:=a;
for b:=1 to r do
write(f[b]:3);
writeln;
repeat
a:=r;
while f[a]=n-r+a do dec(a);
if a<=0 then exit;
inc(f[a]);
for b:=a+1 to r do
f[b]:=f[b-1]+1;
for b:=1 to r do
write(f[b]:3);
writeln;
until a=0;
close(input);close(output);
end.