// biu~ 2019 miss  solo 2022
// AFO Today
// 嘤嘤嘤

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define il inline
#define fo(_var,_a,_b) for(int _var=_a;_var<=_b;_var++)
#define fr(_var,_a,_b) for(int _var=_a;_var>=_b;_var--)
#define clr(_arr,_val) memset(_arr,_val,sizeof(_arr))

struct node
{
    int pos,id;
}now[1010];

int T;
int n,m,k;
int a[1010],up[1010];

il void solve1()
{
    while(T--)
    {
        scanf("%d%d%d",&n,&m,&k);
        fo(i,1,m)
        {
            scanf("%d",&a[i]);
        }
        fo(i,1,2*n)
        {
            now[i].pos=0;
            now[i].id=0;
        }
        fo(i,1,n)
        {
            up[i]=0;
        }
        deque<node> q;
        deque<string> ans;
        fo(i,1,n)
        {
            node tmp;
            tmp.id=i;
            tmp.pos=-1;
            q.push_back(tmp);
            tmp.pos=1;
            q.push_back(tmp);
        }
        string tmp;
        fo(i,1,m)
        {
            if(now[a[i]].pos==0)
            {
                now[a[i]]=q.front();
                q.pop_front();
                tmp="1 "+to_string(now[a[i]].id);
                ans.push_back(tmp);
                up[now[a[i]].id]=now[a[i]].pos==1?i:0;
            }
            else if(now[a[i]].pos==1)
            {
                tmp="1 "+to_string(now[a[i]].id);
                ans.push_back(tmp);
                q.push_front(now[a[i]]);
                now[a[i]].pos=0;
                now[a[i]].id=0;
            }
            else if(now[a[i]].pos==-1)
            {
                tmp="1 "+to_string(n);
                ans.push_back(tmp);
                tmp="2 "+to_string(now[a[i]].id)+' '+to_string(n);
                ans.push_back(tmp);
                if(up[now[a[i]].id]!=0)
                {
                    now[a[up[now[a[i]].id]]].pos=-1;
                    up[now[a[i]].id]=0;
                    now[a[i]].pos=1;
                    q.push_back(now[a[i]]);
                    now[a[i]].pos=0;
                    now[a[i]].id=0;
                }
                else
                {
                    q.push_back(now[a[i]]);
                    now[a[i]].pos=0;
                    now[a[i]].id=0;
                }
                
            }
        }
        cout<<ans.size()<<endl;
        while(!ans.empty())
        {
            cout<<ans.front()<<endl;
            ans.pop_front();
        }
    }
    return ;
}

il void solve2()
{
    while(T--)
    {
        scanf("%d%d%d",&n,&m,&k);
        fo(i,1,m)
        {
            scanf("%d",&a[i]);
        }
        deque<string> ans;
        deque<int> q;
        fo(i,1,m)
        {
            if(!q.empty())
            {
                if(a[i]==q.back())
                {
                    ans.push_back("1 1\n");
                    q.pop_back();
                }
                else if(a[i]==q.front())
                {
                    ans.push_back("1 2\n");
                    ans.push_back("2 1 2\n");
                    q.pop_front();
                }
                else
                {
                    ans.push_back("1 1\n");
                    q.push_back(a[i]);
                }
            }
            else
            {
                ans.push_back("1 1\n");
                q.push_back(a[i]);
            }
        }
        cout<<ans.size()<<endl;
        while(!ans.empty())
        {
            cout<<ans.front();
            ans.pop_front();
        }
    }
    return ;
}

int main()
{
    freopen("meow.in","r",stdin);
    freopen("meow.out","w",stdout);

    scanf("%d",&T);
    if(T%1000==1)
    {
        solve1();
    }
    if(T%1000==2)
    {
        solve2();
    }
    return 0;
}