x1, x2, x3, x4, x5 = list(map(int, input().split()))



if x1 == 0:

  print((1))

elif x2 == 0:

  print((2))

elif x3 == 0:

  print((3))

elif x4 == 0:

  print((4))

else:

  print((5))
x = list(map(int, input().replace(' ','')))

x = list(x)



for idx in range(len(x)):

  if x[idx] == 0:

    print((idx + 1))

    break
x1, x2, x3, x4, x5 = list(map(int, input().split()))
if x1 == 0:
    print((1))
elif x2 == 0:
    print((2))
elif x3 == 0:
    print((3))
elif x4 == 0:
    print((4))
else:
    print((5))

x = list(map(int, input().replace(" ", "")))
x = list(x)
for idx in range(len(x)):
    if x[idx] == 0:
        print((idx + 1))
        break

-x1, x2, x3, x4, x5 = list(map(int, input().split())) -if x1 == 0: -    print((1)) -elif x2 == 0: -    print((2)) -elif x3 == 0: -    print((3)) -elif x4 == 0: -    print((4)) -else: -    print((5)) +x = list(map(int, input().replace(" ", ""))) +x = list(x) +for idx in range(len(x)): +    if x[idx] == 0: +        print((idx + 1)) +        break