#include <bits/stdc++.h>
#ifdef LOCAL
#include <prettyprint>
#define print(x) cerr << x << "\n";
#else
#define print(x)
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323
#endif
#define EPS 1e-6
#define int int_fast64_t

using namespace std;

void solve(){
    int n;
    cin >> n;
    int in1=0, in2=1;
    for (int t = 0; t < n*n; t++){
        int c;
        cin >> c;
        if (c !=1&&in1 < n*n) {
            int x = in1%n;
            int y = in1/n;
            cout << "1 " << x+1 << " " << y+1 << endl;
            in1+=2;
            if (n%2 ==0) {
                if (in1/n > y) {
                    if (y %2 ==0) in1++;
                    else in1--;
                }
            }
        }else if (c !=2 && in2 < n*n) {
            int x = in2%n;
            int y = in2/n;
            cout << "2 " << x+1 << " " << y+1 << endl;
            in2+=2;
            if (n%2 ==0) {
                if (in2/n > y) {
                    if (y %2 ==0) in2--;
                    else in2++;
                }
            }
        }else if (in1 < n*n) {
            int x = in1%n;
            int y = in1/n;
            cout << "3 " << x+1 << " " << y+1 << endl;
            in1+=2;
            if (n%2 ==0) {
                if (in1/n > y) {
                    if (y %2 ==0) in1++;
                    else in1--;
                }
            }
        }else if (in2 < n*n) {
            int x = in2%n;
            int y = in2/n;
            cout << "3 " << x+1 << " " << y+1 << endl;
            in2+=2;
            if (n%2 ==0) {
                if (in2/n > y) {
                    if (y %2 ==0) in2--;
                    else in2++;
                }
            }
        }
    }
  
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int N = 1;
    for (int i = 0; i < N; i++){
        solve();
    } 
}
