#include <iostream>
#include <deque>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

const int MAXN=302;
const int MAXM=2e6+5;
int a[MAXN];
struct op
{
    int oop,s1,s2;
    op(int ss1,int ss2)
    {
        oop=2,s1=ss1,s2=ss2;
    }
    op(int ss1)
    {
        oop=1,s1=ss1;
    }
    void print()
    {
        if(oop==1)
            cout<<1<<' '<<s1<<endl;
        else
            cout<<2<<' '<<s1<<' '<<s2<<endl;
    }
};


int main()
{
    ios::sync_with_stdio(false);
    freopen("meow.in","r",stdin);
    freopen("meow.out","w",stdout);
    int T;
    cin>>T;
    int TT=T;
    while(T--)
    {
        vector<op> ops;
        int n,m,k;
        cin>>n>>m>>k;
        deque<int> sts;
        for(int i=1;i<=m;i++)
            cin>>a[i];
        if(TT==1001 || TT==1)
        {
            vector<int> place(k+1);
            for(int i=1;i<place.size();i++)
                place[i]=-1;
            queue<int> avail;
            for(int i=1;i<=2*n-2;i++)
                avail.push(i);
            for(int i=1;i<=m;i++)
            {
                if(place[a[i]]==-1)
                {
                    place[a[i]]=avail.front();
                    avail.pop();
                    ops.push_back(op(place[a[i]]<=n-1?place[a[i]]:place[a[i]]-(n-1)) );
                }
                else
                {
                    if(place[a[i]]<=n-1)
                    {
                        ops.push_back(op(n));
                        ops.push_back(op(place[a[i]],n));
                    }
                    else
                    {
                        ops.push_back(op(place[a[i]]-(n-1) ));
                    }
                    avail.push(place[a[i]]);
                    place[a[i]]=-1;
                }
            }
            cout<<ops.size()<<endl;
            for(int i=0;i<ops.size();i++)
                ops[i].print();
        }
        if(TT=1002)
        {
            int ss[3][4];
            memset(ss,0,sizeof(ss));
            vector<bool> expose(4);
            for(int i=1;i<=3;i++)
                expose[i]=true;

        }
    }
}//How difficult!I can only get 15 points.
