def check(table, i, j, direction_dict):
dol = table[i][j]
flag = False
for key, direction in direction_dict.items():
flag2 = False
for di, dj in zip(direction['di'], direction['dj']):
i2 = i + di
j2 = j + dj
if i2 >= 19 or j2 >= 19 or i2 < 0 or j2 < 0:
flag2 = True
break
if table[i2][j2] != dol:
flag2 = True
break
if flag2:
continue
flag3 = False
for di6, dj6 in zip(direction['check_i6'], direction['check_j6']):
i6 = i + di6
j6 = j + dj6
if i6 < 19 and j6 < 19 and i6 >= 0 and j6 >= 0:
if table[i6][j6] == dol:
flag3 = True
break
if flag3:
continue
flag = True
break
return flag
if __name__=='__main__':
table = [[0 for _ in range(19)] for _ in range(19)]
direction_dict = {
'row': {
'di': [0, 0, 0, 0],
'dj': [1, 2, 3, 4],
'check_i6': [0, 0],
'check_j6': [5, -1]
},
'col': {
'di': [1, 2, 3, 4],
'dj': [0, 0, 0, 0],
'check_i6': [5, -1],
'check_j6': [0, 0]
},
'cross_down': {
'di': [1, 2, 3, 4],
'dj': [1, 2, 3, 4],
'check_i6': [5, -1],
'check_j6': [5, -1]
},
'cross_up': {
'di': [-1, -2, -3, -4],
'dj': [1, 2, 3, 4],
'check_i6': [-5, 1],
'check_j6': [5, -1]
}
}
for i in range(19):
row = list(map(int, input().split()))
for j in range(19):
table[i][j] = row[j]
flag = False
for i in range(19):
if flag:
break
for j in range(19):
if table[i][j] != 0:
if check(table, i, j, direction_dict):
print(table[i][j])
print('{} {}'.format(i + 1, j + 1))
flag = True
break
if not flag:
print(0)