#include<bits/stdc++.h>
//#define int long long //__int128
const int MAXN = 1e5+3;
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;//0x3f3f3f3f3f3f3f3f;
using namespace std;
int T;
int n,m,k;
int a[MAXN];
int cnt;
struct op
{
	int opt,s1,s2;
}ops[MAXN];

deque<int> st[MAXN];
inline bool checktp(int t){
	if(t>n-1)t-=n-1;
	return st[t].size()&&st[t].front()==t;
}
inline bool checkbk(int t){
	if(t>n-1)t-=n-1;
	return st[t].size()&&st[t].back()==t;
}
inline void add1(int t){
	int ori = t;
	if(t>n-1)t-=n-1;
	ops[++cnt] = {1,t,0};
	if(checktp(ori)){st[t].pop_back();return;}
	else st[t].push_front(ori);
}
inline void add2(int t){
	if(t>n-1)t-=n-1;
	ops[++cnt] = {1,n,0};
	ops[++cnt] = {2,n,t};
}
void work() {
	cin>>n>>m>>k;
	cnt = 0;
	for(int i =0;i<=n;i++)st[i].clear();
	for(int i = 1;i<=m;i++)cin>>a[i];
	for(int i = 1;i<=m;i++){
		if(checkbk(a[i])){add2(a[i]);}
		else if(checktp(a[i])){add1(a[i]);}
		else if(!checktp(a[i])&&!checkbk(a[i]))add1(a[i]);
	}
	cout<<cnt<<"\n";
	for(int i = 1;i<=cnt;i++){
		if(ops[i].opt==1){
			cout<<1<<" "<<ops[i].s1;
		}else{
			cout<<2<<" "<<ops[i].s1<<" "<<ops[i].s2;
		}
		cout<<"\n";
	}
	return;
}
signed main() {
//	ios::sync_with_stdio(0);cin.tsie(0);cout.tie(0);
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	cin>>T;
	while(T--)
	work();
	return 0;
}
