#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10;
int T, n, m, k;
int a[MAXN];
vector<int> v[MAXN];
int l[MAXN], r[MAXN];
struct node {
	int opt, l, r;
};
void work()
{
	vector<node> ans;
	cin >> n >> m >> k;
	for (int i = 1; i <= m; i++)
		cin >> a[i];
	for (int i = 1; i <= m; i++)
	{
		int x = a[i], flag = 0;
		for (int j = 1; j < n; j++)
		{
			if (v[j].size() > r[j] && x == v[j][r[j]])
			{
				ans.push_back({1, j, -1});
				r[j]--;
				v[j].pop_back();
				flag = 1;
				break;
			}
			else if (v[j].size() > l[j] && x == v[j][l[j]])
			{
				ans.push_back({1, n, -1});
				ans.push_back({2, j, n});
				l[j]++;
				flag = 1;
				break;
			}
		}
		if (flag) continue;
		for (int j = 1; j < n; j++)
			if (l[j] == r[j])
			{
				ans.push_back({1, j, -1});
				r[j]++;
				v[j].push_back(x);
				flag = 1;
				break;
			}
		if (flag) continue;
		int pos = rand() % (n - 1) + 1;
		ans.push_back({1, pos, -1});
		v[pos].push_back(x);
		r[pos]++;
	}
	for (int len = 1; len <= 50; len++)
	{
		int fg = 0;
		for (int i = 1; i < n; i++)
			for (int j = 1; j < n; j++)
				while (l[i] < v[i].size() && l[j] < v[j].size() && v[i][l[i]] == v[j][l[j]])
				{
					ans.push_back({2, i, j});
					l[i]++, l[j]++;
					fg = 1;
				}
		if (!fg)
			break;
	}
	cout << ans.size() << endl;
	for (auto c : ans)
	{
		cout << c.opt << ' ';
		if (c.opt == 1)
			cout << c.l << endl;
		else
			cout << c.l << ' ' << c.r << endl;
	}
}
signed main()
{
	freopen("meow.in", "r", stdin);
	freopen("meow.out", "w", stdout);
	cin >> T;
	while(T--)
		work();
	return 0;
}
