#include<bits/stdc++.h>
using namespace std;
int main(){
	int T,max,n,m,a[500050],k;
	queue<int> q;
	int s[500050]={0};
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	scanf("%d",T);
	int t=T;
	while(t--){
		memset(s,0,sizeof(s));
		max=0;
		while(!q.empty()) q.pop();
		scanf("%d%d%d",&n,&m,&k);
		for(int i=1;i<=m;i++){
			scanf("%d",&a[i]);
		}
		if(T==1002){
			for(int i=1;i<=m;i++){
				if(a[i]==s[max]){
					max--;
					cout<<"1 "<<"1"<<endl;
					continue;
				}
				if(q.front()==a[i]){
					q.pop();
					cout<<"2 1 2";
				}
				max++;
				s[max]=a[i];
			}
		}
	}
}
