#include<cstdio>
using namespace std;
int T,n,m,k,a[10005],stk[1005][1005],top[1005];
int main() {
	freopen("meow.in", "r", stdin);
	freopen("meow.out", "w", stdout);
	scanf("%d", &T);
	if (T % 1000==1) {
		while (T--) {
			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++) {	
				for (int i=1; i<=n; i++)
					for (int j=i+1; j<=n; j++) {
						if (stk[j][1]==stk[i][1]) 
							printf("2 %d %d", i, j);	
					}
				for (int j=1; j<=n; j++) {
					if (stk[j][top[j]]==a[i]) {
						printf("1 %d", j);
						top[j]--;
					}
					else if (top[j]==0) {
						printf("1 %d", j);
						stk[j][++top[j]]=a[i];
					}
				}
			
			}
		}
	}
	return 0;
}