#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define mk make_pair
#define pb push_back
using namespace std;
const int N=1e6+10,M=310,inf=1e9+7;
int n,m,k;
int b[M],f[N],ans[N],q[M];
int check(int x)
{
    int mx1=-1,mx2=0;
    for(int i=2;i<=n;i++)
        if(q[i]<=x)if(q[i]>mx1)mx1=q[i],mx2=i;
    return mx2;
}
void solve()
{
    memset(b,0,sizeof(b));
    memset(q,0,sizeof(q));
    scanf("%d%d%d",&n,&m,&k);
    for(int i=1;i<=n;i++)f[i]=0,ans[i]=0;
    for(int i=1,x;i<=m;i++)
    {
        scanf("%d",&x);
        if(b[x])f[b[x]]=i,f[i]=b[x],b[x]=0;
        else b[x]=i;
    }
    int lim=n,tot=m;
    for(int i=1;i<=m;i++)
    {
        if(f[i]<i){lim++;continue;}
        int p=check(i);
        if(f[i]<=lim&&p)
        {
            ans[i]=ans[f[i]]=p;
            q[p]=f[i];
            continue;
        }
        p=check(f[i]);
		if(!p)
		{
			for(int j=2;j<=n;j++)printf("%d ",q[j]);puts("");
			cout<<i<<' '<<f[i]<<endl;puts("SB");exit(1);
		}
        q[1]=i;q[p]=f[i];
        ans[i]=1,ans[f[i]]=p;tot++;
    }
    printf("%d\n",tot);
    for(int i=1;i<=m;i++)
    {
        printf("1 %d\n",ans[i]);
        if(f[i]<i&&ans[i]!=ans[f[i]])printf("2 %d %d\n",ans[i],ans[f[i]]);
    }
}
int main()
{
    freopen("meow.in","r",stdin);
    freopen("meow.out","w",stdout);
    int _;scanf("%d",&_);
    while(_--)solve();
    return 0;
}
/*
首先，可以消牌堆使得相邻两项都是不同的卡牌
*/