
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <sstream>

using namespace std;

#define R 10
#define PSIZE 5

int T[10][10];
int N;

int mid = (PSIZE - 1) / 2;
int p[3][5][5]{
	{0,0,0,0,0,
	0,0,1,0,0,
	0,1,1,1,0,
	0,0,1,0,0,
	0,0,0,0,0},

	{0,0,0,0,0,
	0,1,1,1,0,
	0,1,1,1,0,
	0,1,1,1,0,
	0,0,0,0,0},

	{0,0,1,0,0,
	0,1,1,1,0,
	1,1,1,1,1,
	0,1,1,1,0,
	0,0,1,0,0}
};

void add_point(int x, int y, int point[5][5]) {
	for (int i = 0; i < PSIZE; i++) {
		for (int j = 0; j < PSIZE; j++) {
			if (y + i - mid < 0 || y + i - mid >= R) continue;
			if (x + j - mid < 0 || x + j - mid >= R) continue;
			T[y + i - mid][x + j - mid] += point[i][j];
		}
	}
}

void delete_point(int x, int y, int point[5][5]) {
	for (int i = 0; i < PSIZE; i++) {
		for (int j = 0; j < PSIZE; j++) {
			if (y + i - mid < 0 || y + i - mid >= R) continue;
			if (x + j - mid < 0 || x + j - mid >= R) continue;
			T[y + i - mid][x + j - mid] -= point[i][j];
		}
	}
}

bool validT() {
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < R; j++) {
			if (T[i][j] < 0) return false;
		}
	}
	return true;
}

bool checkT() {
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < R; j++) {
			if (T[i][j] != 0) return false;
		}
	}
	return true;
}

vector<pair< pair<int, int>, int> > points;
bool rec(int cnt) {
	if (checkT()) return true;
	if (cnt == 12) return false;

	for (int i = 1; i < R-1; i++) {
		for (int j = 1; j < R-1; j++) {
			if (!T[j][i]) continue;
			for (int k = 0; k < 3; k++) {
				delete_point(i, j, p[k]);
				if (validT()) {
					points.push_back(make_pair(make_pair(i, j), k));
					if (rec(cnt + 1)) return true;
					points.pop_back();
				}
				add_point(i, j, p[k]);
			}
		}
	}

	return false;
}

void q91() {
	scanf("%d\n", &N);
	for (int i = 0; i < R; i++) {
		string line;
		getline(cin, line);
		istringstream ss(line);
		string str;
		int j = 0;
		for (; getline(ss, str, ' ');) {
			T[i][j++] = atoi(str.c_str());
		}
	}
	bool ans = rec(0);
	for (auto it = points.begin(); it != points.end(); it++) {
		cout << (*it).first.first << " " << (*it).first.second << " " << (*it).second + 1 << endl;
	}

}

int main() {
	q91();
	return 0;
}