#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int n = 0, f = 1;
	char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-') f = -1;
		ch = getchar();
	}
	while(isdigit(ch)){
		n *= 10, n += ch ^ 48;
		ch = getchar();
	}
	return n * f;
}
inline void write(int n){
	if(n < 0){
		putchar('-');
		n = -n;
	}
	if(n > 9) write(n / 10);
	putchar(n % 10 + 48);
}
int T, n, m, k, a;
int s[310][3];//0:siz  1:base  2:top
pair<int, int> now[610];//pos, sit
int ans[4000010][3], opt;
int main(){
	freopen("meow.in", "r", stdin);
	freopen("meow.out", "w", stdout);
	T = read();
	while(T--){
		opt = 0;
		n = read(), m = read(), k = read();
		for(int i = 1; i <= m; i++){
			a = read();
			if(now[a].first == 0){
				for(int i = 1; i <= n; i++){
					if(s[i][0] == 2) continue;
					if(s[i][0] == 1){
						s[i][2] = a;
						s[i][0] = 2;
						now[a] = make_pair(i, 2);
					} else {
						s[i][1] = a;
						s[i][0] = 1;
						now[a] = make_pair(i, 1);
					}
					ans[++opt][0] = 1;
					ans[opt][1] = i;
					break;
				}
			} else {
				if(now[a].second == 2){
					ans[++opt][0] = 1;
					ans[opt][1] = now[a].first;
				} else {
					ans[++opt][0] = 1;
					ans[opt][1] = n;
					ans[++opt][0] = 2;
					ans[opt][1] = now[a].first;
					ans[opt][2] = n;
				}
				now[a] = make_pair(0, 0);
			}
		}
		write(opt);
		putchar(10);
		for(int i = 1; i <= opt; i++){
			if(ans[i][0] == 1){
				putchar(49);
				putchar(32);
				write(ans[i][1]);
				putchar(10);
			} else {
				putchar(50);
				putchar(32);
				write(ans[i][1]);
				putchar(32);
				write(ans[i][2]);
				putchar(10);
			}
		}
	}
	return 0;
}
/*
又被发现啦 
//freopen
freeopen
feropen
freopen("meow.in", "w", stdout);
freopen("meow.out", "r", stdin);

只会贪心乱搞的写法，复杂度O(nm)，只在前三个点有正确性，手造样例开O2跑了1.5s，很危险 
期望得分[0,15] 
*/
