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

int main() {
    int n;
    cin >> n;
    vector<pair<int,int>>tmp1,tmp2;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(i%2 == j%2) {
                tmp1.push_back({i+1,j+1});
            }
            else {
                tmp2.push_back({i+1,j+1});
            }
        }
    }
    for(int i = 0; i < n*n; i++) {
        int a;
        cin >> a;
        if(a != 1) {
            if(tmp1.size()) {
                cout << 1 << " " << tmp1[0].first << " " << tmp1[0].second << endl;
                tmp1.erase(tmp1.begin());
            }
            else {
                if(a == 2) {
                    cout << 3 << " " << tmp2[0].first << " " << tmp2[0].second << endl;
                    tmp2.erase(tmp2.begin());
                }
                else {
                    cout << 2 << " " << tmp2[0].first << " " << tmp2[0].second << endl;
                    tmp2.erase(tmp2.begin());
                }
            }
        }
        else {
            if(tmp2.size()) {
                cout << 2 << " " << tmp2[0].first << " " << tmp2[0].second << endl;
                tmp2.erase(tmp2.begin());
            }
            else {
                cout << 3 << " " << tmp1[0].first << " " << tmp1[0].second << endl;
                tmp1.erase(tmp1.begin());
            }
        }
    }
}
