#include<bits/stdc++.h>
#define rr return
#define RS 2220
#define ll long long 
#define f(a,b,c) for(int c=a;c<=b;c++)
#define ff(a,b,c) for(int c=a;c>=b;c--)
using namespace std;
const int mod = 998244353;
const int inf = 2000010;
#define gc getchar
int rd(){
	int v=1,w=0;
	char c=gc();
	while(c<'0'||c>'9'){
		if(c=='-') v=-1;
		c=gc();
	}
	while(c>='0'&&c<='9'){
		w=(w<<1)+(w<<3)+(c&15);
		c=gc();
	} rr v*w;
}
int t,n,m,k,cnt,a[inf],f[RS],p1[RS],vc[RS],p2[RS];
struct lp{ int op,l,r;}ans[RS];
signed main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	t=rd();
	while(t--){ int nw=1;
		n=rd(); m=rd(); k=rd();
		f(1,m,i) a[i]=rd(),p1[i]=-1;
		f(1,m,i){
			if(p1[a[i]]==1){//1 shang
				p1[a[i]]=-1;
				cnt++;
				ans[cnt].op=1;
				ans[cnt].l=p2[a[i]];
			}else if(p1[a[i]]==-1){//-1 wu
				if(p1[a[i+1]]==1){
					cnt++;
					ans[cnt].op=1;
					ans[cnt].l=p2[a[i]];
				}
				ct1[a[i]]++;
				p1[a[i]]=1;
				p2[a[i]]=nw;
				f[nw]++;
				while(f[nw]==2){
					if(nw==n) nw=1;
					else nw++;
				}
			}
		}
	}
	rr 0;
}