program bianmawenti;
var
q,n,m,i,j,t,s,k,w,jilu:longint;
a,b:array[1..100] of longint;
biaozhi:array[1..100]of boolean;
begin
assign (input,'code.in');
reset (input);
assign (output,'code.out');
rewrite (output);
readln (n,m);
for i:=1 to n do
begin
readln (s);
if s=1 then
begin
for j:=1 to m do
read (a[j]);
readln;
write ('0',' ');
for j:=2 to m do
for k:=1 to j-1 do
if a[k]<a[j] then
b[j]:=b[j]+1;
for j:=2 to m do
write (b[j],' ');
writeln
end
else
begin
for j:=1 to m do
biaozhi[j]:=true;
for j:=1 to m do
read(a[j]);
for j:=m downto 1 do
begin
t:=0;
q:=0;
repeat
q:=q+1;
if biaozhi[q]=true then
t:=t+1;
until t=a[j]+1;
biaozhi[q]:=false;
b[j]:=q-1
end;
for j:=1 to m do
write (b[j],' ');
writeln
end
end;
close (input);
close (output)
end.