#!ruby -pal00F\n
$y=0
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|i==j}}