#include <bits/stdc++.h>
using namespace std;
const int N = 301, M = 2e6 + 1, K = 600;
struct Ans{
int opt;
int s1;
int s2;
Ans(int opt, int s1, int s2) : opt(opt), s1(s1), s2(s2){};
};
int tot, a[M], lst[K];
bool tag[N];
deque<int> dq[N];
queue<Ans> q;
int main(){
// freopen("test.in", "r", stdin);
// freopen("test.out", "w", stdout);
int t;
scanf("%d", &t);
while (t--){
int n, m, k;
scanf("%d%d%d", &n, &m, &k);
for (int i = 1; i <= m; i++)
scanf("%d", &a[i]);
for (int i = 1; i <= m; i++){
if (lst[a[i]]){
if (dq[lst[a[i]]].size() == 2) tot--;
if (dq[lst[a[i]]].back() != a[i]){
// if (dq[lst[a[i]]].empty()) cout << -1 << endl;
dq[lst[a[i]]].pop_front();
q.push(Ans(1, n, 0));
q.push(Ans(2, lst[a[i]], n));
}
else{
// if (dq[lst[a[i]]].empty()) cout << -1 << endl;
dq[lst[a[i]]].pop_back();
q.push(Ans(1, lst[a[i]], 0));
}
lst[a[i]] = 0;
}
else if (tot != n - 1){
for (int j = 1; j <= n; j++)
if (dq[j].size() < 2){
q.push(Ans(1, j, 0));
dq[j].push_back(a[i]);
lst[a[i]] = j;
if (dq[j].size() == 2) tot++;
break;
}
}
else if (a[i + 1] == a[i]){
q.push(Ans(1, n, 0));
q.push(Ans(1, n, 0));
i++;
}
else{
int j = i + 1;
while (j <= m && (dq[lst[a[j]]].back() == a[j] || tag[lst[a[j]]])){
tag[lst[a[j++]]] = true;
// if (j > m) cout << -1 << endl;
}
q.push(Ans(1, lst[a[j]], 0));
dq[lst[a[j]]].push_back(a[i]);
lst[a[i]] = lst[a[j]];
for (int k = i + 1; k < j; k++)
tag[lst[a[k]]] = false;
}
}
printf("%d\n", q.size());
while (!q.empty()){
Ans res = q.front();
printf("%d %d", res.opt, res.s1);
if (res.s2) printf(" %d", res.s2);
printf("\n"), q.pop();
}
}
return 0;
}