
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()

int main(void){
  int const H = 14,W = 14;
  vvi grid (H,vi(W));
  int n ; cin >> n ;
  loop(i,2,H-2){
    loop(j,2,W-2){
      cin >> grid[i][j] ;
    }
  }
  int cnt = 0;
  
  loop(i,2,H-2){
    loop(j,2,W-2){
      if(grid[i][j] && grid[i+4][j] && 
	 (grid[i+2][j-2] == grid[i][j] && grid[i+2][j+2] == grid[i][j] ) &&
	 grid[i+1][j+1] == grid[i][j] && grid[i+1][j-1] == grid[i][j] &&
	 grid[i+3][j+1] == grid[i][j]  && grid[i+3][j-1] == grid[i][j] ){
	//big 
	grid[i][j]--;grid[i+4][j]--;
	grid[i+2][j+2]--;grid[i+2][j-2]--;
	grid[i+1][j]--;grid[i+1][j+1]--;grid[i+1][j-1]--;
	grid[i+2][j]--;grid[i+2][j+1]--;grid[i+2][j-1]--;
	grid[i+3][j]--;grid[i+3][j+1]--;grid[i+3][j-1]--;
	cout<< i + 2  - 2 << " " << j - 2  << " " << 3 << endl;
	n--;

  
	}else 	if(grid[i][j] && grid[i][j+1] && grid[i][j+2]){
	//mid
	grid[i  ][j]--;grid[i  ][j+1]--;grid[i  ][j+2]--;
	grid[i+1][j]--;grid[i+1][j+1]--;grid[i+1][j+2]--;
	grid[i+2][j]--;grid[i+2][j+1]--;grid[i+2][j+2]--;
	cout << j + 1 - 2 << " " << i + 1 - 2 << " " << 2 << endl;
	n--;
	 
      }else if(grid[i][j] && grid[i+2][j]){
	//small	  
	grid[i][j]--;
	grid[i+1][j]--;
	grid[i+1][j-1]--;grid[i+1][j+1]--;
	grid[i+2][j]--;
	n--;
	cout<< j - 2 << " " << i + 1 - 2 << " " << 1 << endl;
	    
      }
      if(n<=0)break;
    }

    if(n<=0)break;
  }
    
}