/*
.
*/
#include <bits/stdc++.h>
using namespace std;

#define il inline
#define ll long long
#define oup(x) wrt(x),ptc(' ')
#define oun(x) wrt(x),ptc('\n')
#define gtc getchar()
#define ptc putchar
#define rd read()
#define rdl readl()
il int read(){int x=0;bool f=0;char c=gtc;while(c<'0'||c>'9'){if(c=='-')f=1;c=gtc;}while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=gtc;}return f?-x:x;}
il ll readl(){ll x=0;bool f=0;char c=gtc;while(c<'0'||c>'9'){if(c=='-')f=1;c=gtc;}while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=gtc;}	return f?-x:x;}
il void wt(ll x){if(x>10)wt(x/10);ptc(x%10+48);}
il void wrt(ll x){if(x<0)ptc('-'),wt(-x);else wt(x);}

namespace sol1{

const int N = 310;
int tl[N];
int hd[N];
int ans[4000010][3];

il void work(int T){
	while(T--){
		int n = rd, m = rd, k = rd;
		int l = n - 1, x;
		int step = 0;
		for(int i = 1; i <= m; i++){
			x = rd;
			int z = (x - 1) % l + 1;
			if(!hd[z]) hd[z] = x, ans[++step][0] = 1, ans[step][1] = z;
			else{
				if(hd[z] == x){
					if(!tl[z]){
						ans[++step][0] = 1, ans[step][1] = z;
						hd[z] = 0;
					}
					else{
						ans[++step][0] = 1, ans[step][1] = n;
						ans[++step][0] = 2, ans[step][1] = z, ans[step][2] = n;
						hd[z] = tl[z];
						tl[z] = 0;
					}
				}else{
					if(!tl[z]){
						tl[z] = x;
						ans[++step][0] = 1, ans[step][1] = z;
					}
					else{
						ans[++step][0] = 1, ans[step][1] = z;
						tl[z] = 0;
					}
				}
			}
		}
		oun(step);
		for(int i = 1; i <= step; i++){
			oup(ans[i][0]);
			if(ans[i][0] == 1){
				oun(ans[i][1]);
			}else{
				oup(ans[i][1]),oun(ans[i][2]);
			}
		}
	}
	exit(0);
}

}

#define FL "meow"
int main(){

	freopen(FL".in","r",stdin);
	freopen(FL".out","w",stdout);

	int T = rd;
	if(T % 10 == 1){sol1::work(T);return 0;}
//	if(T % 10 == 2){sol2::work(T);return 0;}

	return 0;
}
/*
1
2 4 2
1 2 1 2

*/

