#include<bits/stdc++.h>
using namespace std;
const int M = 2e6 + 10, N = 3e2 + 10;
int T;
int n, m, k;
int a[M];
deque < int > stk[N];
int idx; 
struct op {
	int id;
	int u, v;
}lst[M];
int p(int x) {
	return (x - 1)/2 + 1;
} 
signed main()
{
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	
	scanf ("%d", &T);
	
	while (T -- ) {
		
		idx = 0;
		for (int i = 1; i <= n; i ++ ) while (!stk[i].empty()) stk[i].pop_back();
		
		scanf ("%d%d%d", &n, &m, &k);
		for (int i = 1; i <= m; i ++ ) {
			scanf ("%d", &a[i]);
		}
		
		for (int i = 1; i <= m; i ++ ) {
			if ( stk[ p(a[i]) ].empty() ) {
				stk[p(a[i])].push_front(a[i]);
				lst[++idx] = (op){1, p(a[i]), 0};
			} else if ( stk[p(a[i])].front() == a[i] ) {
				lst[++idx] = (op){1, p(a[i]), 0};
				stk[p(a[i])].pop_front();
			} else if ( stk[ p(a[i]) ].front() != a[i] && stk[ p(a[i]) ].back() != a[i]) {
				lst[++idx] = (op){1, p(a[i]), 0};
				stk[p(a[i])].push_front(a[i]);
			} else if ( stk[ p(a[i]) ].front() != a[i] && stk[ p(a[i]) ].back() == a[i]) { 
				lst[++idx] = (op){1, n, 0};
				lst[++idx] = (op){2, n, p(a[i])};
				stk[p(a[i])].pop_back();
			}
		}
		
		printf("%d\n", idx);
		
		for (int i = 1; i <= idx; i ++ ) {
			if (lst[i].id == 1) {
				printf("1 %d\n", lst[i].u);
			} else if (lst[i].id == 2) {
				printf("2 %d %d\n", lst[i].u, lst[i].v);
			}
		}
		
	}
	
	return 0;
}
/*
1
2 4 2
1 2 1 2
*/
