#include<bits/stdc++.h>
using namespace std;
const int N=305;
int T,n,m,k,a[N];
deque<int>s[N];
vector<pair<int,int>>ans;
int main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	scanf("%d",&T);
	while(T--){
		scanf("%d%d%d",&n,&m,&k);
		for(int i=1;i<=m;i++)
			scanf("%d",a+i);
		for(int i=1;i<=m||!s[1].empty()||!s[2].empty();){
			if(!s[1].empty()&&s[1].front()==a[i])ans.emplace_back(1,0),s[1].pop_front(),i++;else
			if(!s[2].empty()&&s[2].front()==a[i])ans.emplace_back(2,0),s[2].pop_front(),i++;else
			if(!s[1].empty()&&!s[2].empty()&&s[1].back()==s[2].back())ans.emplace_back(1,2),s[1].pop_back(),s[2].pop_back();else
			if(s[1].empty())ans.emplace_back(1,0),s[1].push_front(a[i]),i++;else ans.emplace_back(2,0),s[2].push_front(a[i]),i++;
		}
		printf("%d\n",ans.size());
		for(auto v:ans){
			if(v.second)printf("%d %d %d\n",2,v.first,v.second);
			else printf("%d %d\n",1,v.first);
		}
	}
	return 0;
}