L=[int(x) for x in input().split(" ")]

print((L.index(0)+1))
L=[int(x) for x in input().split(" ")]

print((L.index(0)+1))

L.clear()
L = [int(x) for x in input().split(" ")]
print((L.index(0) + 1))

L = [int(x) for x in input().split(" ")]
print((L.index(0) + 1))
L.clear()

+L.clear()