//what is meow le ge meow?????
//how to play it?????
#include<bits/stdc++.h>
using namespace std;
int m,n,s,cnt,t,id,c,k;
int a;
deque<int>st[310];
int tp[200010];
int t1[400010],t2[400010],t3[400010];
bool f=0;
void dfs(int p) {
	// can i mo ni it???
	if(p>m+1)return;
	if(f)return;
	if(p==m+1) {
		for(int i=1; i<=n; i++) {
			if(!st[i].empty())return;
		}
		if(cnt>2*m)return;
		cout<<cnt<<endl;
		for(int i=1; i<=cnt; i++) {
			if(t3[i]==1) {
				cout<<1<<' '<<t1[i]<<endl;
			} else if(t3[i]==2) {
				cout<<2<<' '<<t1[i]<<' '<<t2[i]<<endl;
			}
		}
		f=1;
		return;
	}
	for(int i=1; i<=n; i++) {
		if(st[i].empty())continue;
		for(int j=i+1; j<=n; j++) {
			if(st[j].empty())continue;
			if(st[j].front()==st[i].front()) {
				st[j].pop_front();
				st[i].pop_front();
				t3[++cnt]=2;
				t1[cnt]=i;
				t2[cnt]=j;
			}
		}
	}
	for(int i=1; i<=n; i++) {
		cnt++;
		t3[cnt]=1;
		t1[cnt]=i;
		if(!st[i].empty()) {
			if(st[i].back()==tp[p]) {
				st[i].pop_back();
				dfs(p+1);
				if(f)return;
				st[i].push_back(tp[p]);
			} else {
				st[i].push_back(tp[p]);
				dfs(p+1);
				if(f)return;
				if(!st[i].empty())st[i].pop_back();
			}
		} else {
			st[i].push_back(tp[p]);
			dfs(p+1);
			if(f)return;
			if(!st[i].empty())st[i].pop_back();
		}
		cnt--;
	}
	//no i cant!
}
int main() {
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	scanf("%d",&t);
	while(t--) {
		f=0;
		cnt=0;
		scanf("%d%d%d",&n,&m,&k);
		for(int i=1; i<=m; i++) { //unlimited m???????????
			scanf("%d",&tp[i]);
		}
		dfs(1);
	}
	return 0;
}
//meow~
