#include<bits/stdc++.h>
using namespace std;
int n, m, T, k, a[10000010];
int read()
{
	int x = 0, f = 1;
	char c = getchar();
	while(c != EOF and !isdigit(c))
	{
		if(c == '-')f = -1;
		c = getchar();
	}
	while(isdigit(c))
	{
		x = x * 10 + c - '0';
		c = getchar();
	}
	return x * f;
}
int f[310][2];
vector<pair<int, int> >ans;
void sub1()
{
	while(T --)
	{
		ans.clear();
		memset(f, 0, sizeof(f));
		n = read();
		m = read();
		k = read();
		for(int i = 1;i <= m;i ++)
		{
			a[i] = read();
			int x = a[i] % (n - 1) + 1;
			if(f[x][0] and f[x][1])
			{
				if(a[i] == f[x][0])
				{
					ans.push_back(make_pair(1, n));
					ans.push_back(make_pair(2, x));
					f[x][0] = f[x][1];
					f[x][1] = 0;
					continue;
				}
				if(a[i] == f[x][1])
				{
					ans.push_back(make_pair(1, x));
					f[x][1] = 0;
					continue;
				}
			}
			else if(f[x][0])
			{
				ans.push_back(make_pair(1, x));
				if(a[i] == f[x][0])
				{
					f[x][0] = 0;
					continue;
				}
				else
				{
					f[x][1] = a[i];
					continue;
				}
			}
			else
			{
				ans.push_back(make_pair(1, x));
				f[x][0] = a[i];
				continue;
			} 
		}
		int siz = ans.size();
		printf("%d\n", siz);
		for(int i = 0;i < ans.size();i ++)
		{
			int fir = ans[i].first, se = ans[i].second;
			if(fir == 1)printf("1 %d\n", se);
			if(fir == 2)printf("2 %d %d\n", se, n);
		}
	}
	return ;
}
signed main()
{
	freopen("meow.in", "r", stdin);
	freopen("meow.out", "w", stdout);
	T = read();
	if(T % 10 == 1)
	{
		sub1();
		return 0;
	}
	while(T --)
	{
		ans.clear();
		n = read();
		m = read();
		k = read();
		for(int i = 1;i <= m;i ++)a[i] = read();
		for(int i = 1;i <= m;i ++)
		{
			if(a[i] == f[1][2])
			{
				ans.push_back(make_pair(1, 1));
				f[1][2] = 0;
				continue;
			}
			if(a[i] == f[2][0])
			{
				ans.push_back(make_pair(1, 2));
				f[2][0] = 0;
				continue;
			}
			if(a[i] == f[2][1])
			{
				ans.push_back(make_pair(1, 2));
				f[2][1] = 0;
				continue;
			}
			if((! f[1][2]) and f[1][1] and a[i] == f[1][1])
			{
				ans.push_back(make_pair(1, 1));
				f[1][1] = 0;
				continue;
			}
			if((! f[1][1]) and f[1][0] and a[i] == f[1][0])
			{
				ans.push_back(make_pair(1, 1));
				f[1][0] = 0;
				continue;
			}
			if(f[1][0] and f[1][1])
			{
				if(a[i + 1] == f[1][0])
				{
					ans.push_back(make_pair(1, 1));
					f[1][2] = a[i];
				}
				if(a[i + 1] == f[1][1])
				{
					ans.push_back(make_pair(1, 2));
					f[2][0] = a[i];
				}
				continue;
			}
			if(f[2][0] and f[2][1])
			{
				if(a[i + 1] == f[2][0])
				{
					ans.push_back(make_pair(1, 2));
					f[1][2] = a[i];
				}
				if(a[i + 1] == f[2][1])
				{
					ans.push_back(make_pair(1, 1));
					f[2][0] = a[i];
				}
				continue;
			}
			if(f[1][0])
			{
				ans.push_back(make_pair(1, 1));
				f[1][0] = a[i];
				continue;
			}
			if(f[2][0])
			{
				ans.push_back(make_pair(1, 2));
				f[2][0] = a[i];
				continue;
			}
		}
		int siz = ans.size();
		printf("%d\n", siz);
		for(int i = 0;i < ans.size();i ++)
		{
			int fir = ans[i].first, se = ans[i].second;
			if(fir == 1)printf("1 %d\n", se);
			if(fir == 2)printf("2 %d %d\n", se, n);
			if(fir == 3)printf("2 %d %d\n", 1, se);
		}
	}
	return 0;
}

