K = int(eval(input()))



a = 7 % K



for i in range(999983):

    if a == 0:

        print((i+1))

        exit()

    a = (a * 10 + 7) % K



print((-1))
K = int(eval(input()))

 

a = 7 % K

 

for i in range(K):

    if a == 0:

        print((i+1))

        exit()

    a = (a * 10 + 7) % K

 

print((-1))
K = int(eval(input()))
a = 7 % K
for i in range(999983):
    if a == 0:
        print((i + 1))
        exit()
    a = (a * 10 + 7) % K
print((-1))

K = int(eval(input()))
a = 7 % K
for i in range(K):
    if a == 0:
        print((i + 1))
        exit()
    a = (a * 10 + 7) % K
print((-1))

-for i in range(999983): +for i in range(K):