#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <stack>
#include <numeric>
#include <ctime>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <map>

using namespace std;
typedef long long int lint;

class Point {
public:
	int x;
	int y;
	int size;

	Point(int bx, int by, int bsize){
		x = bx, y = by, size = bsize;
	}
};

int n;
int a[10][10] = {};
int sum;
int cx, cy;
stack<Point> st;

void printAns()
{
	while (!st.empty()){
		cout << st.top().x << " " << st.top().y << " " << st.top().size << endl;
		st.pop();
	}
}

void popBlur(int x, int y, int size)
{
	if (size == 1){
		a[y][x]--; a[y][x - 1]--; a[y][x + 1]--; a[y - 1][x]--; a[y + 1][x]--;
		sum -= 5;
	}
	else if (size == 2){
		for (int dy = -1; dy <= 1; dy++){
			for (int dx = -1; dx <= 1; dx++){
				a[y + dy][x + dx]--;
			}
		}
		sum -= 9;
	}
	else {
		for (int dy = -1; dy <= 1; dy++){
			for (int dx = -1; dx <= 1; dx++){
				a[y + dy][x + dx]--;
			}
		}
		a[y][x - 2]--; a[y][x + 2]--; a[y - 2][x]--; a[y + 2][x]--;
		sum -= 13;
	}
}

void pushBlur(int x, int y, int size)
{
	if (size == 1){
		a[y][x]++; a[y][x - 1]++; a[y][x + 1]++; a[y - 1][x]++; a[y + 1][x]++;
		sum += 5;
	}
	else if (size == 2){
		for (int dy = -1; dy <= 1; dy++){
			for (int dx = -1; dx <= 1; dx++){
				a[y + dy][x + dx]++;
			}
		}
		sum += 9;
	}
	else {
		for (int dy = -1; dy <= 1; dy++){
			for (int dx = -1; dx <= 1; dx++){
				a[y + dy][x + dx]++;
			}
		}
		a[y][x - 2]++; a[y][x + 2]++; a[y - 2][x]++; a[y + 2][x]++;
		sum += 13;
	}
}

bool judge(int x, int y, int size)
{
	if (size == 1){
		if (y == 0 || y == 9 || x == 0 || x == 9) return false;
		if (!a[y][x] || !a[y][x - 1] || !a[y][x + 1] || !a[y - 1][x] || !a[y + 1][x]) return false;
		return true;
	}
	else if (size == 2){
		if (y == 0 || y == 9 || x == 0 || x == 9) return false;
		for (int dy = -1; dy <= 1; dy++){
			for (int dx = -1; dx <= 1; dx++){
				if (!a[y + dy][x + dx]) return false;
			}
		}
		return true;
	}
	else {
		if (y <= 1 || y >= 8 || x <= 1 || x >= 8) return false;
		for (int dy = -1; dy <= 1; dy++){
			for (int dx = -1; dx <= 1; dx++){
				if (!a[y + dy][x + dx]) return false;
			}
		}
		if (!a[y][x - 2] || !a[y][x + 2] || !a[y - 2][x] || !a[y + 2][x]) return false;
		return true;
	}
}
/*
void blur()
{
	for (int size = 1; size <= 3; size++){

		for (int y = 0; y < 10; y++){
			for (int x = 0; x < 10; x++){
				if (judge(x, y, size)){
					popBlur(x, y, size);
					st.push(Point(x, y, size));
					if (sum == 0){
						printAns();
						return;
					}
					blur();
					if (st.empty()) return;
					st.pop();
					pushBlur(x, y, size);
				}
			}
		}

	}
}
*/

void blur()
{
	for (int size = 3; size >= 1; size--){

		while (true){
			if (judge(cx, cy, size)){
				popBlur(cx, cy, size);
				st.push(Point(cx, cy, size));
				if (sum == 0){
					printAns();
					return;
				}
				if ((size == 1 && sum >= 5) || (size == 2 && sum >= 9) || (size == 3 && sum >= 13)){
					blur();
				}
				if (st.empty()) return;
				cx = st.top().x; cy = st.top().y;
				st.pop();
				pushBlur(cx, cy, size);
			}

			if (cx == 9 && cy == 9) {
				cx = 0; cy = 0; break;
			}
			else if (cx == 9) {
				cx = 0; cy++;
			}
			else {
				cx++;
			}
		}

	}
}

int main()
{
	cin >> n;
	sum = 0;
	for (int y = 0; y < 10; y++){
		for (int x = 0; x < 10; x++){
			cin >> a[y][x];
			sum += a[y][x];
		}
	}

	cx = 0; cy = 0;
	blur();

	return 0;
}