#ifndef TheCodeWasMadeByMooos
#define TheCodeWasMadeByMooos
#include<bits/stdc++.h>
#define endl '\n'
#define QAQ(n, m) for(ll i = n; i <= m; ++i)
#define QWQ(n, m) for(ll j = n; j <= m; ++j)
#define For(i, n, m) for(ll i = n; i <= m; ++i)
#define uQWQ(n, m) for(ll j = n; j >= m; --j)
#define uQAQ(n, m) for(ll i = n; i >= m; --i)
#define uFor(i, n, m) for(ll i = n; i >= m; --i)
#define FOpen(x) freopen (#x".in", "r", stdin), freopen (#x".out", "w", stdout)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll T, n, m, k;
ll OptCnt;
struct Opt { ll Type, s1, s2; } Opt[2000010];
// inline void AddOpt (Opt A) { Opt[++OptCnt] = A; }
inline void PrintOpt () {
	cout << OptCnt << endl;
	QAQ (1, OptCnt) {
		cout << Opt[i].Type << ' ';
		if (Opt[i].Type == 2) cout << Opt[i].s1 << ' ' << Opt[i].s2 << endl;
		else cout << Opt[i].s1 << endl;
	}
}
namespace Sub1 {
	vector<ll>St[301]; ll Tmp;
    inline void Solve () {
		cin >> n >> m >> k;
		QAQ (1, n) St[i].reserve (2);
		QAQ (1, m) {
			static ll a, In;
			cin >> a, In = (a + 1) / 2;
			switch (St[In].size ()) {
			case 0:
				Opt[++OptCnt] = { 1, In, 0 };
				St[In].push_back (In);
				break;
			case 1:
				Opt[++OptCnt] = { 1, In, 0 };
				if (St[In].back () == a) St[In].pop_back ();
				else St[In].push_back (a);
				break;
			case 2:
				if (St[In].back () == a)
					Opt[++OptCnt] = { 1, In, 0 },
					St[In].pop_back ();
				else
					Opt[++OptCnt] = { 1, n, 0 },
					Opt[++OptCnt] = { 2, In, n },
					Tmp = St[In][1], St[In].clear (), St[In].push_back (Tmp);
					// St[In] = { St[In][1] };
				break;
			}
		}
		PrintOpt ();
	}
}
// namespace Sub3 {
// 	bool Got;
// 	ll a[15], L[4], R[4], St[4][20], Ck[10], EmptyStCnt;
// 	inline void DFS (ll Pos = 1) {
// 		if (Pos == m + 1) {
// 			if (EmptyStCnt == n) PrintOpt (), Got = true;
// 			return;
// 		}
// 		QAQ (1, n) {
// 			if (L[i] == R[i] && Ck[i]) {
// 				ll Tmp = Ck[i];
// 				Opt[++OptCnt] = { 1, i, 0 },
// 				Opt[++OptCnt] = { 2, i, Ck[i] },
// 				++L[Ck[i]], Ck[i] = 0;
// 				if (L[T] == R[T]) ++EmptyStCnt, DFS (Pos + 1), --EmptyStCnt;
// 				else DFS (Pos + 1);
// 				--L[Ck[i]], Ck[i] = Tmp, OptCnt -= 2;
// 			}
// 			else if (L[i] == R[i]) {
// 				--EmptyStCnt,
			
// 			}
// 		}
// 	}
// 	inline void Solve () {
// 		cin >> n >> m >> k; QAQ (1, m) cin >> a[i];
// 		EmptyStCnt = n, Got = false, DFS ();
// 	}
// }
int main () {
	FOpen (meow), cin.tie (0), ios::sync_with_stdio (false);
	cin >> T;
    if (T % 10 == 1) while (T--) Sub1::Solve ();
	// if (T == 3) while (T--) Sub3::Solve ();
}
#endif