var
n,m,i,j,s,t,k:longint;
a,b,f:array[0..1000]of longint;
begin
assign(input,'code.in'); reset(input);
assign(output,'code.out'); rewrite(output);
readln(m,n);
for i:=1 to n do f[i]:=i;
for i:=1 to m do
begin
read(s);
for j:=1 to n do read(a[j]);
case s of
1:begin
b[1]:=0;
for j:=2 to n do
begin
for k:=1 to j-1 do
if a[k]<a[j] then inc(b[j]);
end;
end;
2:begin
for j:=n downto 1 do
begin
t:=0;
k:=0;
while t<=b[j] do
begin
inc(k);
if f[k]>-1 then inc(t);
end;
b[j]:=f[k]-1; f[k]:=-1;
end;
end;
end;
for k:=1 to n-1 do write(b[k],' ');
writeln(b[n])
end;
close(input);
close(output)
end.