#include<bits/stdc++.h>
#define ll long long
#define rep(i, l, r) for (int i=l, _=r; i<=_; i++)
#define per(i, l, r) for (int i=l, _=r; i>=_; i--)
using namespace std;

inline ll read() {
    ll s=0, t=0; char ch=getchar();
    for (; ch<'0'||ch>'9'; ch=getchar()) if (ch=='-') t=1;
    for (; ch>='0'&&ch<='9'; ch=getchar()) s=s*10+ch-'0';
    return t?-s:s;
}
const int M=605;
int T;
namespace solve1{
    int a[M], t, n, m, k, st[M][M], top[M], fr[M];
    struct ANS{int x, y;} ans[M];
    void print() {
        printf("%d\n", t);
        rep(i, 1, t)
            if (!ans[i].y) printf("1 %d\n", ans[i].x);
            else printf("2 %d %d\n", ans[i].x, ans[i].y);
    }
    bool check() {
        bool ok2=1;
        rep(i, 1, n) if (fr[i]<=top[i]) {ok2=0; break;}
        return ok2;
    }
    bool dfs(int d) {
        if (d>m) {
            rep(i, 1, n) fr[i]=1;
            t=m;
            while (1) {
                bool ok=1;
                rep(i, 1, n) if (fr[i]<top[i]&&st[i][fr[i]]==st[i][fr[i]+1]) fr[i]+=2;
                if (check()) return print(), 1;
                rep(i, 1, n) {
                    rep(j, i+1, n) if (fr[i]<=top[i]&&fr[j]<=top[j]&&st[i][fr[i]]==st[j][fr[j]]) {
                        fr[i]++; fr[j]++;
                        ans[++t]={i, j};
                        ok=0; break;
                    }
                    if (ok==0) break;
                }
                if (ok) return 0;
                if (check()) return print(), 1;
            }
            return 0;
        }
        rep(i, 1, n) {
            ans[d]={i, 0};
            st[i][++top[i]]=a[d];
            if (dfs(d+1)) return 1;
            st[i][top[i]--]=0;
        }
        return 0;
    }
    void solve() {
        for (; T; T--) {
            n=read(), m=read(), k=read();
            rep(i, 1, m) a[i]=read();
            rep(i, 1, n) top[i]=0;
            dfs(1);
        }
    }
}
namespace solve2 {
    int a[M], st[M][2], n, m, k, ans[M];
    void print() {
        int t=0;
        rep(i, 1, m) t+=ans[i];
        printf("%d\n", t);
        rep(i, 1, m) {
            if (ans[i]==1) printf("1 %d\n", a[i]>>1);
            else printf("1 %d\n 2 %d %d\n", n, n, a[i]>>1);
        }
    }
    inline void mak(int i) {
        if (st[i>>1][0]==a[i]) ans[i]=2;
        else {
            ans[i]=1;
            if (st[i>>1][1]==a[i]) st[i>>1][1]=0;
        }
    }
    void solve() {
        for (; T; T--) {
            n=read(), m=read(), k=read();
            rep(i, 1, m) a[i]=read(), mak(i);
            print();
        }
    }
}
int main() {
    freopen("meow.in", "r", stdin);
    freopen("meow.out", "w", stdout);
    T=read();
    if (T%10==1) solve2::solve();
    else solve1::solve();
}