#include <bits/stdc++.h>
#include <tuple>
using namespace std;
const int MAX=int(2e6+5);
int T,n,m,k;
int in[MAX];
int hd[MAX],pre[MAX],nxt[MAX];
int ptr;
bool done;
deque<int> q[305];
deque<int> cq[305];
deque<vector<int> > ans;
int seed=1145;
bool search(int i) {
//	cout<<i<<endl;
	bool ret=false;
	if(i==m+1) {
		for(int i=1; i<=n; i++) {
			cq[i]=deque<int>();
			for(auto it=q[i].begin(); it!=q[i].end(); it++) {
				cq[i].push_back(*it);
			}
		}
		bool update=true;
		while(update) {
			update=false;
			for(int j=1; j<=n; j++) {
				for(int l=j+1; l<=n; l++) {
					if(cq[l].empty() or cq[j].empty()) {
						continue;
					}
					if(cq[j].front()==cq[l].front()) {
						cq[j].pop_front();
						cq[l].pop_front();
						update=true;
						ans.push_front(vector<int>({2,j,l}));
					}
				}
			}
		}
		for(int i=1; i<=n; i++) {
			if(!cq[i].empty()) {
				ans.clear();
				return false;
			}
		}
//		cout<<"t";
		return true;
	}
	
	for(int j=1; j<=n; j++) {
		if(!q[j].empty() and q[j].back()==in[i]) {
			q[j].pop_back();;
			ret = search(i+1);
			if(ret) {
				ans.push_back(vector<int>({1,j,0}));
				return true;
			}
			q[j].push_back(in[i]);
		} else {
			q[j].push_back(in[i]);
			ret = search(i+1);
			if(ret) {
				ans.push_back(vector<int>({1,j,0}));
				return true;
			}
			q[j].pop_back();
		}
	}
	return false;
}
int main() {
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	scanf("%d",&T);
	while(T--) {
		memset(in,0,sizeof(in));
		scanf("%d%d%d",&n,&m,&k);
		for(int i=1; i<=m; i++) {
			scanf("%d",&in[i]);
		}
		search(1);
		printf("%d\n",int(ans.size()));
		while(!ans.empty()) {
			auto pp=ans.back();
			ans.pop_back();
			cout<<pp[0]<<" ";
			for(int i=1; i<=pp[0]; i++) {
				cout<<pp[i]<<" ";
			}
			cout<<endl;
		}
	}
	return 0;
}
