#include<cstdio>
//1.long long 2.1ll 3.%lld 4.xiabiao
using namespace std;
const int MAXN=310,MAXK=610;
inline long long rd()
{
	char ch=getchar();
	long long f=1ll,s=0;
	while(ch>'9' || ch<'0')
	{
		if(ch=='-')
			f=-1ll;
		ch=getchar();
	}
	while(ch<='9' && ch>='0')
	{
		s=(s<<3)+(s<<1)+ch-48;
		ch=getchar();
	}
	return s*f;
}
long long n,m,k,a[MAXN],xb[MAXN],tong[MAXK];
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	long long T;
	T=rd();
while(T--)
{
	n=rd();m=rd();k=rd();
	for(int i=1;i<=m;i++)
		a[i]=rd();
	
	
	for(int i=m;i>=1;i--)
	{
		if(tong[a[i]]==0)
			xb[i]=-1;else
			xb[i]=tong[a[i]];
		tong[a[i]]=i;
	}
	//xb[i] zuihouyige jiejinde
	for(int i=1;i<=m;i++)
		printf("%lld ",xb[i]);
	//st[i][j] duilie   sl[i] sr[i]
	//dst[i] dst[0]=length
	for(int i=1;i<=m;i++)
	{
		if(tongtop[a[i]])
		{
			czs++;
			cz[i][0]=1;
			cz[i][1]=tongtop[a[i]];
			sr[tongtop[a[i]]]--;
			if(sl!=sr)
				tongtop[a[i]]=0;
			tongtop[a[i]]=0;

		}
		//a[i] down gengxin
		if(tost[a[i]]!=0)
		{
			sl[tost[a[i]]]++;
			tost[a[i]]=0;
			printf("%d")
			continue;
		
		}
	}
	
	
	
}
	return 0;
}