#include <bits/stdc++.h>

using namespace std;
int n;
vector<int> px,py,qx,qy;
int lp,lq;

inline void pp(int x) {
	cout << x << " " << px[lp] << " " << py[lp]  << endl;
	lp++;
}

inline void qq(int x) {
	cout << x << " " << qx[lq] << " " << qy[lq] <<endl;
	lq++;
}

int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0;i < n; i++) {
		for (int j = 0;j < n; j++) {
			if ((i+j)%2 == 0) {
				px.push_back(i+1);
				py.push_back(j+1);
			}
			else {
				qx.push_back(i+1);
				qy.push_back(j+1);
			}
		}
	}
	int x;
	for (int i = 1;i <= n*n; i++) {
		scanf("%d",&x);
		if (x == 1) {
			if (lp == px.size()) {
				qq(3);
			}
			else {
				pp(2);
			}
		}
		else if (x == 2) {
			if (lq == qx.size()) {
				pp(3);
			}
			else {
				qq(1);
			}
		}
		else {
			if (lp == px.size()) {
				qq(1);
			}
			else {
				pp(2);
			}
		}
	}
	return 0;
} 