import java.util.Scanner;
public class Main {
static final int[] dx = {-1,0,1,1};
static final int[] dy = {1,1,1,0};
static final int[] check = {-1, 5};
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int win = 0;
int[][] ba = new int[19][19];
for (int i = 0; i < ba.length; i++) {
for (int j = 0; j < ba[0].length; j++) {
ba[i][j] = sc.nextInt();
}
}
end:for (int i = 0; i < ba.length; i++) {
for (int j = 0; j < ba[0].length; j++) {
int x = i;
int y = j;
if(ba[x][y] == 1 || ba[x][y] ==2) {
int omok = ba[x][y];
here:for (int k = 0; k < dx.length; k++) {
x = i;
y = j;
for (int h = 0; h < 4; h++) {
x+=dx[k];
y+=dy[k];
if(x >=0 && x < ba.length && y >=0 && y < ba.length) {
if(ba[x][y] == omok) {
continue;
}else continue here;
}else continue here;
}
chk:for (int k2 = 0; k2 < check.length; k2++) {
int nx = i + check[k2]*dx[k];
int ny = j + check[k2]*dy[k];
if(nx >=0 && nx < ba.length && ny >=0 && ny < ba.length) {
if(ba[nx][ny] != omok) {
continue chk;
}continue here;
}
}
win = 1;
System.out.printf("%d\n", omok);
System.out.printf("%d %d", i+1, j+1 );
break end;
}
}
}
}
if(win != 1) System.out.println(0);
sc.close();
}
}