program code;
var
a,b:array[0..101] of integer;
c:array[0..101] of boolean;
m,n,i,j,k,p,s:integer;
begin
assign(input,'code.in');
reset(input);
assign(output,'code.out');
rewrite(output);
readln(m,n);
for k:=1 to m do
begin
readln(s);
fillchar(a,sizeof(a),0);
fillchar(b,sizeof(b),0);
if s=1 then
begin
for i:=1 to n do
read(a[i]);
readln;
for i:=1 to n do
begin
for j:=1 to i-1 do
if a[i]>a[j]
then inc(b[i])
end;
for i:=1 to n do
write(b[i],' ');
writeln
end
else
begin
for i:=1 to n do
read(b[i]);
readln;
fillchar(c,sizeof(c),true);
for i:=n downto 1 do
begin
p:=0;
for j:=0 to n-1 do
if c[j] then
begin
inc(p);
if p>b[i] then
begin
a[i]:=j;
c[j]:=false;
break
end
end
end;
for i:=1 to n do
write(a[i],' ');
writeln
end
end;
close(input);
close(output)
end.