#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define lowbit(x) ((x)&(-(x)))
#define mid ((l+r)>>1)
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid+1, r
#define fors(i, a, b) for(int i = (a); i < (b); ++i)
#define all(vec) vec.begin(),vec.end()
using namespace std;
int n;
#define P pair<int,int>
queue<P> q[2];
int main()
{
    int n; cin>>n;
    fors(i,1,n+1){
        fors(j,1,n+1){
            int x = (i+j)&1;
            q[x].push(P(i,j));
        }
    }
    fors(i,1,n*n+1){
        int x; cin>>x;

        if(q[0].size() == 0){
            int c = 2;
            if(x == c) c = 3;
            P p = q[1].front(); q[1].pop();
            int a,b; tie(a,b) = p;
            cout<<c<<" "<<a<<" "<<b<<endl;
        }else if(q[1].size() == 0){
            int c = 1;
            if(x == c) c = 3;
            P p = q[0].front(); q[0].pop();
            int a,b; tie(a,b) = p;
            cout<<c<<" "<<a<<" "<<b<<endl;
        }else{
            if(x == 1){
                P p = q[1].front(); q[1].pop();
                int a,b; tie(a,b) = p;
                cout<<2<<" "<<a<<" "<<b<<endl;
            }else {
                P p = q[0].front(); q[0].pop();
                int a,b; tie(a,b) = p;
                cout<<1<<" "<<a<<" "<<b<<endl;
            }
        }
        cout.flush();
    }
	return 0;
}
