k=int(input())

x=i=0

while i<7e6:i+=1;x=(x*10+7)%k;x<1>exit(print(i))

print(-1)

k=int(input())

x=i=0

while i<k:i+=1;x=(x*10+7)%k;x<1>exit(print(i))

print(-1)

k = int(input())
x = i = 0
while i < 7e6:
    i += 1
    x = (x * 10 + 7) % k
    x < 1 > exit(print(i))
print(-1)

k = int(input())
x = i = 0
while i < k:
    i += 1
    x = (x * 10 + 7) % k
    x < 1 > exit(print(i))
print(-1)

-while i < 7e6: +while i < k: