#include<bits/stdc++.h>
#define Lyr_ids trash
#define ccf our_red_sun
using namespace std;
typedef long long ll;
namespace IO
{
	char buf[1<<20],*iS,*iT;
	#define gh() (iS==iT?iT=(iS=buf)+fread(buf,1,1<<20,stdin),(iS==iT?EOF:*iS++):*iS++)
	template<typename T>
	inline void read(T &x)
	{
		x=0;
		char c=gh();
		bool sgn=0;
		while(!isdigit(c))
			sgn|=c=='-',c=gh();
		while(isdigit(c))
			x=x*10+(c^48),c=gh();
		x=sgn?-x:x;
	}
}
using namespace IO;
int t,n,m,k,op;
const int maxn=305;
const int maxm=2e6+5;
int cd[maxm];
vector<int>col[maxn];
struct Opt{
	int id,x,y;
	Opt(int id_=0,int x_=0,int y_=0)
	{
		id=id_,x=x_,y=y_;
	}
//	Opt(int id_=0,int x_=0)
//	{
//		id=id_,x=x_;
//	}
};
vector<Opt>ans;
int main()
{
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	read(t);
	for(int kkk=0;kkk<t;++kkk)
	{
		read(n),read(m),read(k);
		if(k==2*n-2)
		{
			for(int i=1;i<=m;++i)
			{
				read(cd[i]);
				if(cd[i]>=n)
					++cd[i];
				if(col[cd[i]%n].empty())
				{
					ans.emplace_back(Opt(1,cd[i]%n,0));
					col[cd[i]%n].emplace_back(cd[i]);
					continue;
				}
				if(col[cd[i]%n].back()==cd[i])
				{
					ans.emplace_back(Opt(1,cd[i]%n,0));
					col[cd[i]%n].pop_back();
					continue;
				}
				ans.emplace_back(Opt(1,n,0));
				ans.emplace_back(Opt(2,cd[i]%n,n));
				col[cd[i]%n].erase(col[cd[i]%n].begin());
			}
			printf("%d\n",ans.size());
			for(const Opt &v:ans)
			{
				if(v.id==1)
					printf("1 %d\n",v.x);
				else
					printf("2 %d %d\n",v.x,v.y);
			}
		}
		else
		{
			if(n==2)
			{
				for(int i=1;i<=m;++i)
					read(cd[i]);
				for(int i=1;i<=m;++i)
				{
					if(cd[i]==1)
					{
						;
					}
				}
			}
			else
			{
				puts("0");
			}
		}
		ans.clear();
		for(int i=1;i<=n;++i)
			col[i].clear();
	}
	return 0;
}

