#include<bits/stdc++.h>
using namespace std;
#define ll long long
int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-') f=-1;
		c=getchar();
	}
	while('0'<=c&&c<='9'){
		x=(x<<3)+(x<<1)+c-'0';
		c=getchar();
	}
	return x*f;
}
const int K=600+10,M=2e6+10;
int T,n,m,k;
int mp[K];
int a[M];
void putin(){
	int cnt=0;
	n=read();m=read();k=read();
	for(int i=1;i<=m;i++){
		a[i]=read();
		if(mp[a[i]]==0){
			mp[a[i]]=++cnt;
		}
		a[i]=mp[a[i]];
	}
}
int main()
{
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	T=read();
	while(T--){
		putin();
	}
}
