#include<bits/stdc++.h>
#define For(i,l,r) for(int i=(l);i<=(r);++i)
const int N=2000010;
using namespace std;
deque<int> s[310];
int T,n,m,k;
int a[N];
struct Ans
{
	int opt,x,y;
}ans[N<<1];
void solve()
{
	For(i,1,300)
	{
		while(s[i].size())
			s[i].pop_front();
	}
	int tot=0;
	For(i,1,m)
		scanf("%d",&a[i]);
	For(i,1,m)
	{
		int x=a[i],num;
		if(x>=n)
			num=x+1-n;
		else if(x<n)
			num=x;
		if(s[num].size()>=1)
		{
			if(s[num].front()==x)
			{
				++tot;
				ans[tot].opt=1;
				ans[tot].x=n;
				++tot;
				ans[tot].opt=2;
				ans[tot].x=num;
				ans[tot].y=n;
				s[num].pop_front();
			}
			else if(s[num].back()==x)
			{
				++tot;
				ans[tot].opt=1;
				ans[tot].x=num;
				s[num].pop_back();
			}
			else
			{
				++tot;
				ans[tot].opt=1;
				ans[tot].x=num;
				s[num].push_back(x);
			}
		}
		else if(s[num].size()==0)
		{
			++tot;
			ans[tot].opt=1;
			ans[tot].x=num;
			s[num].push_front(x);
		}
	}
	printf("%d\n",tot);
	For(i,1,tot)
	{
		printf("%d ",ans[i].opt);
		if(ans[i].opt==1)
			printf("%d\n",ans[i].x);
		else if(ans[i].opt==2)
			printf("%d %d\n",ans[i].x,ans[i].y);
	}
}
int main()
{
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d%d%d",&n,&m,&k);
		if(k==((n<<1)-2))
			solve();
		else
			continue;
	}
	return 0;
}