import java.util.Scanner;
class Solution {
public static void main(String args[]) throws Exception {
Scanner sc = new Scanner(System.in);
for (int testCase = 1; testCase <= 10; testCase++) {
int z = sc.nextInt();
int arr[][] = new int[100][100];
int y = 0;
for (int i = 0; i < 100; i++) {
for (int j = 0; j < 100; j++) {
int temp = sc.nextInt();
arr[i][j] = temp;
if (i == 99 && temp == 2) {
y = j;
}
}
}
for (int x = 99; x >= 0; x--) {
if (y - 1 >= 0 && arr[x][y - 1] == 1) {
while (y - 1 >= 0 && arr[x][y - 1] == 1) {
y -= 1;
}
}
else if (y + 1 <= 99 && arr[x][y + 1] == 1) {
while (y + 1 <= 99 && arr[x][y + 1] == 1) {
y += 1;
}
}
}
System.out.printf("#%d %d\n", testCase, y);
}
}
}
배열을 입력받고 만약 마지막 행의 값이 2 도착지점
라면 y값에 열 위치 저장
x 행
가 99부터 0이상일때까지 x-- 반복 -> 도착지점부터 출발지점으로 올라감
y 열
는 좌우를 살피며 옆에 갈수있는 길이있다면 옆으로 빠져 갈수있는 만큼 옆으로 감
마지막에 y의 위치 출력