#include<bits/stdc++.h>
using namespace std;
//#define int long long
inline int read() 
{
	int sum = 0, nega = 1; char ch = getchar();
	while(ch > '9' || ch < '0') {if(ch == '-') nega = -1; ch = getchar();}
	while(ch <= '9' && ch >= '0') sum = sum * 10 + ch - '0', ch = getchar();
	return nega * sum;
}
const int N = 609, M = 2e6 + 9;
int n, m, k, a[N], cnt;
vector<int> G[N], s;
struct tt
{
	int opt, x, y;
}q[M];
inline void solve() 
{
	n = read(), m = read(), k = read(); cnt = 0;
	for (int i = 1; i <= max(n, k); i++) G[i].clear();
	for (int i = 1; i <= m; i++) a[i] = read();
	for (int i = 1; i <= m; i++) 
	{
		int t = (a[i] - 1) % (n - 1) + 1; 
		if(G[t].size() >= 1)
		{
			if(G[t][0] == a[i]) 
			{
				q[++cnt] = tt{1, n, 0};
				q[++cnt] = tt{2, t, n}; 
				s.clear();
				for (int j = 1; j < G[t].size(); j++) s.push_back(G[t][j]);
				G[t] = s;
			}
			else  
			{
				q[++cnt] = tt{1, t, 0};
				if(a[i] == G[t][G[t].size() - 1]) 
				{
					s.clear();
					for (int j = 0; j < G[t].size() - 1; j++) s.push_back(G[t][j]);
					G[t] = s;
				}
				else G[t].push_back(a[i]);
			}
		}
		else q[++cnt] = tt{1, t, 0}, G[t].push_back(a[i]);
	}
	printf("%lld\n", cnt);
	for (int i = 1; i <= cnt; i++) 
		if(q[i].opt == 1) printf("1 %lld\n", q[i].x);
		else printf("2 %lld %lld\n", q[i].x, q[i].y);
	return ;
}
signed main()
{
	freopen("meow.in", "r", stdin);
	freopen("meow.out", "w", stdout);
	int T = read();
	for (int ttt = 1; ttt <= T; ttt++) solve();
	return 0;
}
