#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define init(x) memset (x,0,sizeof (x))
#define INF 0x3f3f3f3f
using namespace std;
const int MAX = 2e6 + 5;
const int MOD = 1e9 + 7;
inline int read ();
int t,n,m,k,cnt,a[MAX],up[MAX],dn[MAX];
struct node
{
	int id,x,y;
} ans[MAX << 1];
int main ()
{
	freopen ("meow.in","r",stdin);
	freopen ("meow.out","w",stdout);
	t = read ();
	while (t--)
	{
		n = read ();m = read ();k = read ();
		for (int i = 1;i <= m;++i) a[i] = read ();
		for (int i = 1;i <= k;++i) up[i] = dn[i] = 0;
		if (k == 2 * n - 2)
		{
			int p = 1,st = 0;cnt = 0;
			while (p <= m)
			{
				if (a[p] == a[p + 1]) ans[++cnt] = {1,1,0},ans[++cnt] = {1,1,0},p += 2;
				else 
				{
					bool ok = 0;
					for (int i = 1;i <= n;++i)
					{
						if (up[i] == a[p])
						{
							ans[++cnt] = {1,i,0},up[i] = dn[i];
							ok = 1;
							break;	
						}
					}
					if (ok) {++p;continue;}
					for (int i = 1;i <= n;++i)
					{
						if (dn[i] == a[p])
						{
							ans[++cnt] = {1,n,0},ans[++cnt] = {2,i,n},dn[i] = up[i];
							ok = 1;break;
						}
					}
					if (ok) {++p;continue;}
					++st;
					if (st == n) st = 1;
					ans[++cnt] = {1,st,0};
					up[st] = a[p];
					if (!dn[st]) dn[st] = a[p];
					++p;

				}	
			}
			printf ("%d\n",cnt);
			for (int i = 1;i <= cnt;++i)
			{
				if (ans[i].id == 1) printf ("1 %d\n",ans[i].x);
				else printf ("2 %d %d\n",ans[i].x,ans[i].y);
				ans[i].id = ans[i].x = ans[i].y = 0;
			}
		}
	}
	return 0;
}
inline int read ()
{
	int s = 0,f = 1;
	char ch = getchar ();
	while ((ch < '0' || ch > '9') && ch != EOF)
	{
		if (ch == '-') f = -1;
		ch = getchar ();
	}
	while (ch >= '0' && ch <= '9')
	{
		s = s * 10 + ch - '0';
		ch = getchar ();
	}
	return f * s;
}
