#include<bits/stdc++.h>
using namespace std;
pair<int,int> ans[10000001];
deque<int> dq[301];
int a[2000001];
int main()
{
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int t,n,m,k,p,op,i,j;
	bool f;cin>>t;
	while(t--)
	{
		cin>>n>>m>>k;
		p=0,op=0,f=false;
		for(i=1;i<=m;i++)
		{
			cin>>a[i];
			for(j=1;j<=(f?n:p);j++)
			if(dq[j].size()&&dq[j].back()==a[i])
			{
				ans[++op]=make_pair(j,0);
				dq[j].pop_back();
				goto next;
			}
			if(p<n) p++;
			else p=1,f=true;
			dq[p].push_back(a[i]);
			ans[++op]=make_pair(p,0);
			for(j=1;j<p;j++)
			if(dq[j].size()&&dq[j].front()==a[i])
			{
				ans[++op]=make_pair(j,p);
				dq[j].pop_front();
			}
			next:;
		}
		printf("%d\n",op);for(k=1;k<=op;k++)
		if(ans[k].second) printf("2 %d %d\n",ans[k].first,ans[k].second);
		else printf("1 %d\n",ans[k].first);
	}
	return 0;
}
