program code(input,output);
var
m,n,i,j,k,s,tmp:integer;
a,ans:array[0..99]of integer;
boo:array[0..99]of boolean;
begin
assign(input,'code.in');
reset(input);
assign(output,'code.out');
rewrite(output);
readln(m,n);
for i:=1 to m do
begin
read(s);
for j:=0 to n-1 do
read(a[j]);
if s=1 then
begin
for j:=0 to n-1 do
begin
tmp:=0;
for k:=0 to j-1 do
if a[k]<a[j] then
inc(tmp);
write(tmp,' ');
end;
end
else
begin
for j:=0 to n-1 do
boo[j]:=false;
ans[n-1]:=a[n-1];
boo[ans[n-1]]:=true;
for j:=n-2 downto 0 do
for k:=0 to n-1 do
if not(boo[k]) then
begin
if a[j]>0 then
dec(a[j])
else
begin
ans[j]:=k;
boo[k]:=true;
break;
end;
end;
for j:=0 to n-1 do
write(ans[j],' ');
end;
writeln;
end;
close(input);
close(output);
end.