#include<bits/stdc++.h>
using namespace std;
int T,n,m,k,a[2000005];
int main(){
	#ifndef LOCAL
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	#endif
	ios::sync_with_stdio(0);
	cin >> T;
	while(T--){
		cin >> n >> m >> k;
		for(int i = 1;i <= m;i++){
			cin >> a[i];
		}
		if(T%10==2){
			//case 2 only 2 stacks, k = 3
			vector<int> v1,v2;
			for(int i = 1;i <= m;i++){
				if(v1.size()>0&&v1[v1.size()-1]==a[i]){
					cout << "1 " << 1 << endl;
					v1.pop_back();
					continue;
				}else if(v2.size()>0&&v2[v2.size()-1]==a[i]){
					cout << "1 " << 2 << endl;
					v2.pop_back();
					continue;
				}
				if(v1.size()>0&&v2.size()>0&&v1[0]==v2[0]){
					cout << "2 1 2" << endl;
					vector<int> vv1,vv2;
					for(int i = 1;i < v1.size();i++) vv1.push_back(v1[i]);
					for(int i = 1;i < v2.size();i++) vv2.push_back(v2[i]);
					v1=vv1,v2=vv2;
				}
				cout << "1 " << 1 << endl;
				v1.push_back(1);
			}
			
		}
	}
}