#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

struct Answer {
  int y, x, size;
  Answer(int y_, int x_, int size_) : y(y_), x(x_), size(size_) { }
};
int N;
int board[10][10];
vector<Answer> ans;
bool done;

bool check_small(int y, int x) {
  if(y < 1 || y > 7 || x < 1 || x > 8) return false;
  if(board[y][x] < 1)         return false;
  if(board[y + 1][x - 1] < 1) return false;
  if(board[y + 1][x] < 1)     return false;
  if(board[y + 1][x + 1] < 1) return false;
  if(board[y + 2][x] < 1)     return false;
  return true;
}

bool check_middle(int y, int x) {
  if(y < 0 || y > 7 || x < 0 || x > 7) return false;
  for(int i = 0; i < 3; ++i) {
    for(int j = 0; j < 3; ++j) {
      if(board[y + i][x + j] < 1) return false;
    }
  }
  return true;
}

bool check_large(int y, int x) {
  if(y < 0 || y > 5 || x < 2 || x > 7) return false;
  if(board[y][x] < 1)         return false;
  if(board[y + 1][x - 1] < 1) return false;
  if(board[y + 1][x] < 1)     return false;
  if(board[y + 1][x + 1] < 1) return false;
  if(board[y + 2][x - 2] < 1) return false;
  if(board[y + 2][x - 1] < 1) return false;
  if(board[y + 2][x] < 1)     return false;
  if(board[y + 2][x + 1] < 1) return false;
  if(board[y + 2][x + 2] < 1) return false;
  if(board[y + 3][x - 1] < 1) return false;
  if(board[y + 3][x] < 1)     return false;
  if(board[y + 3][x + 1] < 1) return false;
  if(board[y + 4][x] < 1)     return false;
  return true;
}

void solve(int y, int x) {
  //cerr << __func__ << "(y=" << y  + 1<< ", x=" << x + 1 << ")" << endl;
  //for(auto&& a : ans) {
  //  cerr << "put: " << (a.x + 1) << " " << (a.y + 1) << " " << (a.size + 1) << endl;
  //}
  //for(int y = 0; y < 10; ++y) {
  //  for(int x = 0; x < 10; ++x) {
  //    cerr << board[y][x];
  //  }
  //  cerr << endl;
  //}
  if(done) return;
  if(y > 9) {
    for(auto&& a : ans) {
      cout << (a.x) << " " << (a.y) << " " << (a.size + 1) << endl;
    }
    done = true;
    return;
  }
  if(x > 9) {
    //cerr << "next line " << "(y=" << y  + 1<< ", x=" << x + 1 << ")" << endl;
    solve(y + 1, 0);
    return;
  }
  if(board[y][x] > 0) {
    // small
    if(check_small(y, x)) {
      board[y][x]--;
      board[y + 1][x - 1]--;
      board[y + 1][x]--;
      board[y + 1][x + 1]--;
      board[y + 2][x]--;
      ans.emplace_back(y + 1, x, 0);
      solve(y, x);
      ans.pop_back();
      board[y][x]++;
      board[y + 1][x - 1]++;
      board[y + 1][x]++;
      board[y + 1][x + 1]++;
      board[y + 2][x]++;
    }
    // middle
    if(check_middle(y, x)) {
      for(int i = 0; i < 3; ++i) {
        for(int j = 0; j < 3; ++j) {
          board[y + i][x + j]--;
        }
      }
      ans.emplace_back(y + 1, x + 1, 1);
      solve(y, x);
      ans.pop_back();
      for(int i = 0; i < 3; ++i) {
        for(int j = 0; j < 3; ++j) {
          board[y + i][x + j]++;
        }
      }
    }
    // big
    if(check_large(y, x)) {
      board[y][x]--;
      board[y + 1][x - 1]--;
      board[y + 1][x]--;
      board[y + 1][x + 1]--;
      board[y + 2][x - 2]--;
      board[y + 2][x - 1]--;
      board[y + 2][x]--;
      board[y + 2][x + 1]--;
      board[y + 2][x + 2]--;
      board[y + 3][x - 1]--;
      board[y + 3][x]--;
      board[y + 3][x + 1]--;
      board[y + 4][x]--;
      ans.emplace_back(y + 2, x, 2);
      solve(y, x);
      ans.pop_back();
      board[y][x]++;
      board[y + 1][x - 1]++;
      board[y + 1][x]++;
      board[y + 1][x + 1]++;
      board[y + 2][x - 2]++;
      board[y + 2][x - 1]++;
      board[y + 2][x]++;
      board[y + 2][x + 1]++;
      board[y + 2][x + 2]++;
      board[y + 3][x - 1]++;
      board[y + 3][x]++;
      board[y + 3][x + 1]++;
      board[y + 4][x]++;
    }
    return;
  }
  else {
    solve(y, x + 1);
  }
}

int main() {
  cin >> N;
  for(int i = 0; i < 10; ++i) {
    for(int j = 0; j < 10; ++j) {
      cin >> board[i][j];
    }
  }
  done = false;
  solve(0, 0);
}