#include<bits/stdc++.h>
#define ll long long
#define inf (1<<30)
#define INF (1ll<<60)
#define pii pair<int,int>
#define mkp make_pair
#define fi first
#define se second
#define pb emplace_back
#define siz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define clr(a) memset((a),0,sizeof(a))
#define rep(i,j,k) for(int i=(j);i<=(k);i++)
#define per(i,j,k) for(int i=(j);i>=(k);i--)
#define pt(a) cerr<<#a<<'='<<a<<' '
#define pts(a) cerr<<#a<<'='<<a<<'\n'
using namespace std;
const int MAXN=2e6+10;
struct Opt{
	int op,s1,s2;
	void out(){
		if(op==1) cout<<1<<' '<<s1<<'\n';
		else cout<<2<<' '<<s1<<' '<<s2<<'\n';
	}
};
int p[MAXN];
int n,m,k;
namespace KS{
	int istop[1010],top[310],bot[310];
	vector<Opt> ans;
	void solve(){
		clr(istop);clr(top);clr(bot);ans.clear();
		vector<pii> vld;
		rep(i,1,n-1) vld.pb(mkp(i,1)),vld.pb(mkp(i,-1));
		rep(i,1,m){
			if(!istop[p[i]]){
				pii cur=vld.back();vld.pop_back();
				istop[p[i]]=cur.fi*cur.se;
				ans.pb(Opt{1,cur.fi,0});
				if(cur.se>0) top[cur.fi]=p[i];
				else bot[cur.fi]=p[i];
			}else{
				if(istop[p[i]]<0){
					ans.pb(Opt{1,n,0});
					ans.pb(Opt{2,-istop[p[i]],n});
					bot[-istop[p[i]]]=top[-istop[p[i]]];
					istop[bot[-istop[p[i]]]]*=-1;
					vld.pb(mkp(-istop[p[i]],1));
				}else{
					ans.pb(Opt{1,istop[p[i]],0});
					vld.pb(mkp(istop[p[i]],1));
				}istop[p[i]]=0;
			}
		}cout<<siz(ans)<<'\n';
		rep(i,0,siz(ans)-1) ans[i].out();
	}
}
/*
namespace NO{
	int mat[MAXN],lst[MAXN];
	
	struct node{
		int x,mt;
		bool friend operator<(node a,node b){
			return a.mt>b.mt;
		}
	};
	priority_queue<node> q;
	void solve(){
		rep(i,1,m){
			if(!lst[p[i]]) lst[p[i]]=i;
			else mat[lst[p[i]]]=i,lst[p[i]]=0;
		}
		rep(i,1,m){
			
		}
	}
}
*/
void solve(){
	cin>>n>>m>>k;
	rep(i,1,m) cin>>p[i];
	KS::solve();
}
signed main()
{
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int T;for(cin>>T;T--;)
		solve();
	return 0;
}