#include<iostream>
using namespace std;
int t,n,m,k;
int a[2000005];
int zhansum;
int zhan[305][5];
int main()
{
    freopen("meow1.in","r",stdin);
    freopen("meow.ans","w",stdout);
    cin>>t;
    for(int i=1;i<=t;i++)
    {
        cin>>n>>m>>k;
        for(int j=0;j<m;j++)
        {
            zhansum=1;
            for(int i=0;i<305;i++)
            {
                zhan[i][0]=0;
                zhan[i][1]=0;
            }
            cin>>a[j];
            bool flag=false;
            for(int k=0;k<zhansum;k++)
            {
                if(zhan[k][0]==a[j])
                {
                    cout<<1<<" "<<n<<endl;
                    cout<<2<<" "<<k<<" "<<n<<endl;
                    zhan[k][0]=zhan[k][1];
                    zhan[k][1]=0;
                    flag=true;
                }
                if(zhan[k][1]==a[j])
                {
                    cout<<1<<" "<<k<<endl;
                    zhan[k][1]=0;
                    flag=true;
                }
            }
            if(flag==true)
            {
                continue;
            }
            else{
            if(zhansum<n)
            {
                zhansum++;
                zhan[zhansum-1][0]=a[j];
                cout<<1<<" "<<zhansum-1<<endl;
                continue;
            }
            for(int k=0;k<zhansum;k++)
            {
                if(zhan[k][0]==0)
                {
                    zhan[k][0]==a[j];
                    flag==true;
                }
                else if(zhan[k][1]==0)
                {
                    zhan[k][i]=a[j];
                    flag==true;
                }
            }
            if(flag==true)
            {
                continue;
            }
            else{
            cin>>a[++j];
            for(int k=0;k<zhansum;k++)
            {
                if(zhan[k][0]==a[j])
                {
                    cout<<1<<" "<<n<<endl;
                    cout<<2<<" "<<k<<" "<<n<<endl;
                    zhan[k][0]=zhan[k][1];
                    zhan[k][1]=0;
                    flag=true;
                }
                if(zhan[k][1]==a[j])
                {
                    cout<<1<<" "<<k<<endl;
                    zhan[k][1]=0;
                    flag=true;
                }
            }
            if(a[j-1]==a[j] && flag==false)
            {
                cout<<1<<" "<<n<<endl;
                cout<<1<<" "<<n<<endl;
            }
            //else cout<<"error"<<endl;
            }
            }
        }

    }

    return 0;
}