#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<vector>
#include<numeric>
#include<queue>
using namespace std;
const int __=2e6+6,_=905;
int t,n,m,k,a[__],las[_],bel[_];
deque<int> dq[_];
queue<int>  avai;
bool ok[_];
void sol1(){
    int ai,c;
    vector<pair<int,int>>ops;
    for(int i=1;i<=m;i++){
        cin>>ai,c=((ai+1)>>1);
        if(dq[c].size()&&dq[c].back()==ai)
            ops.push_back({-1,c}),dq[c].pop_back();
        else if(dq[c].size()&&dq[c].front()==ai)
            ops.push_back({-1,c}),ops.push_back({c,n}),
            dq[c].pop_front();
        else
            ops.push_back({-1,c}),dq[c].push_back(ai);
    }
    printf("%d\n",int(ops.size()));
    for(auto ox:ops){
        if(ox.first==-1)printf("1 %d\n",ox.second);
        else printf("2 %d %d\n",ox.first,ox.second);
    }
}
void sol(){
    cin>>n>>m>>k,iota(bel+1,bel+k+1,1);
    // if(k==((n-1)<<1))
    return sol1();
    /*
    for(int i=1;i<=m;i++)
        cin>>a[i],las[a[i]]=i;
    sort(bel+1,bel+k+1,[&](int u,int v){return las[u]>las[v];});
    for(int i=1;i<=m;i++){

    }*/
}
int main(){
    freopen("meow.in","r",stdin);
    freopen("meow.out","w",stdout);
    ios::sync_with_stdio(0),cin.tie(0);
    cin>>t; while(t--) sol();
}