#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10;
int T, n, m, k;
int a[N], flag;
deque<int>d[310];
struct typ{int op, x, y;};
vector<typ>ans;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	freopen("meow.in", "r", stdin);
	freopen("meow.out", "w", stdout);
	cin >> T;
	int op = T % 10;
	while(T --)
	{
		cin >> n >> m >> k;
		int a;
		for (int i = 1; i <= m; ++ i)
		{
			cin >> a;
			if(d[a % (n - 1)].size() && d[a % (n - 1)].back() == a) ans.push_back((typ){1, a % (n - 1) + 1, 0}), d[a % (n - 1)].pop_back();
			else if(d[a % (n - 1)].size() && d[a % (n - 1)].front() == a) ans.push_back((typ){1, n, 0}), ans.push_back((typ){2, a % (n - 1) + 1, n}), d[a % (n - 1)].pop_front();
			else ans.push_back((typ){1, a % (n - 1) + 1, 0}), d[a % (n - 1)].push_back(a);
		}
		cout << ans.size() << "\n";
		for (auto i:ans)
		{
			if(i.op == 1) cout << 1 << " " << i.x << "\n";
			else cout << 2 << " " << i.x << " " << i.y << "\n";
		}
		ans.clear();
	}
}