#include<bits/stdc++.h>
using namespace std;

const int M = 2e6 + 7;
const int N = 307;
int t, n, m, k, a[M], cnt;
struct node {
	int x, y, z;
}opt[2 * M];
stack<int>s[N];

int main() {
	freopen("meow.in", "r", stdin);
	freopen("meow.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> t;
	t = 1;
	while(t--) {
		cin >> n >> m >> k;
		for(int i = 1; i <= m; ++i)
			cin >> a[i];
		for(int i = 1; i <= m; ++i) {
			bool flag = false;
			int minn = s[1].size(), mp = 1;
			for(int j = 1; j <= n; ++j) {
				if(!s[j].empty() && s[j].top() == a[i]) {
					s[j].pop(), opt[++cnt].x = 1, opt[cnt].y = j, flag = true;
					break;
				}
				if(s[j].size() < minn)
					minn = s[j].size(), mp = j;	
			}
			if(!flag)
				s[mp].push(a[i]), opt[++cnt].x = 1, opt[cnt].y = mp;
		}
		cout << cnt << endl;
		for(int i = 1; i <= cnt; ++i)
			cout << 1 << " " << opt[i].y << endl;
	}
	return 0;
}