#include <bits/stdc++.h>

using namespace std;

void solve() {
	int n, m, k;
	cin >> n >> m >> k;
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i]; --a[i];
	}
	vector<array<int, 3>> op;
	vector<deque<int>> stk(n);
	for (int i = 0; i < m; i++) {
		int x = a[i];
		int t = x % n;
		if (stk[t].empty()) {
			stk[t].push_back(x);
			op.push_back(array<int, 3>{1, t + 1, 0});
		} else if (stk[t].back() == x) {
			stk[t].pop_back();
			op.push_back(array<int, 3>{1, t + 1, 0});
		} else {
			stk[t].pop_front();
			op.push_back(array<int, 3>{1, n, 0});
			op.push_back(array<int, 3>{2, t + 1, n});
		}
	}
	cout << (int) op.size() << "\n";
	for (auto x : op) {
		if (x[0] == 1) {
			cout << x[0] << " " << x[1] << "\n";
		} else {
			cout << x[0] << " " << x[1] << " " << x[2] << "\n";
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	freopen("meow.in", "r", stdin);
	freopen("meow.out", "w", stdout);
	int t;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}