#!ruby -pal00F\n
x=$F.find_index{|r|$y=r.index ?1}
n=[
[[1,0],[1,1],[0,1]],
[[1,0],[2,0],[3,0]],
[[0,1],[0,2],[0,3]],
[[1,0],[1,-1],[2,-1]],
[[1,1],[1,2],[0,1]],
[[1,0],[1,1],[2,1]],
[[1,0],[0,1],[1,-1]]].find_index{|p|p.all?{|i,j|$F[x+i][$y+j]==?1}}
$_=[*?A..?G][n]