#include <iostream>
#include <fstream>
using namespace std;
int s1[100],s2[100],a[100];
int i,j;
int m,n;
int ss1()
{
int temp;
for (i=0;i<=n-1;i++)
{
temp=0;
if (i!=0)
{
for (j=0;j<=i-1;j++)
if (s1[j]<s1[i]) temp++;
}
s2[i]=temp;
}
return 0;
}
int ss2()
{
for (i=0;i<=n-1;i++)
a[i]=1;
int temp;
for (i=n-1;i>=0;i--)
{
temp=0;
j=-1;
if (s1[i]!=0)
{
while (temp<s1[i])
{
j++;
if (a[j]==1)
temp++;
}
j++;
}
else
{
j=0;
while (a[j]==0) j++;
}
s2[i]=j;
a[j]=0;
}
return 0;
}
int main()
{
ifstream f1("code.in");
ofstream f2("code.out");
f1>>m>>n;
int p,temp;
for (p=1;p<=m;p++)
{
f1>>temp;
if (temp==1)
{
for (i=0;i<=n-1;i++)
f1>>s1[i];
ss1();
for (i=0;i<=n-1;i++)
f2<<s2[i]<<' ';
f2<<endl;
}
else
{
for (i=0;i<=n-1;i++)
f1>>s1[i];
ss2();
for (i=0;i<=n-1;i++)
f2<<s2[i]<<' ';
f2<<endl;
}
}
f1.close();
f2.close();
return 0;
}