#include <bits/stdc++.h>
#define sz(a) int((a).size())
#define FOR(i, l, r) for(int i = (l); i <= (r); i++)
#define ROF(i, r, l) for(int i = (r); i >= (l); i--)
#define ll long long
#define vi vector<int>
#define ull unsigned long long

using namespace std;
const int N = 2e6 + 10;
int T;
int n, m, k;
int a[N];
int opt[N * 2], s1[N * 2], s2[N * 2], tot;
vector<int> ca[N];
void add1(int x, int y) {
    tot++;
    opt[tot] = 1, s1[tot] = x;
    if(!ca[x].empty() && a[ca[x].back()] == a[y]) {
        ca[x].pop_back();
        return;
    }
    ca[x].emplace_back(y);
}
void add2(int x, int y) {
    tot++;
    opt[tot] = 2, s1[tot] = x, s2[tot] = y;
    if(ca[x].empty() || ca[y].empty()) return;
    if(a[ca[x][0]] == a[ca[y][0]]) {
        ca[x].erase(ca[x].begin());
        ca[y].erase(ca[y].begin());
    }
}
void rmain() {
    tot = 0;
    cin >> n >> m >> k;
    FOR(i, 1, n) ca[i].clear();
    FOR(i, 1, m) cin >> a[i];
    FOR(i, 1, m) {
        int x = (a[i] + 1) / 2;
        int pos = -1;
        FOR(j, 0, sz(ca[x]) - 1) {
            if(a[ca[x][j]] == a[i]) {
                pos = j;
            }
        }
        if(pos == -1) {
            add1(x, i);
        } else if(pos == 0) {
            add1(n, i);
            add2(x, n);
        } else {
            add1(x, i);
        }
    }
    cout << tot << "\n";
    FOR(i, 1, tot) {
        cout << opt[i] << " ";
        if(opt[i] == 1) {
            cout << s1[i] << "\n";
        } else {
            cout << s1[i] <<" " << s2[i] << "\n";
        }
    }
    // FOR(i, 1, n) assert(ca[i].empty());
}
int main() {
    freopen("meow.in", "r", stdin);
    freopen("meow.out", "w", stdout);
    ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
    for(cin >> T; T--; ) rmain();
}
