K = int(eval(input()))

a = 7



for n in range(1,1+K):

  if a%K==0:

    print(n)

    exit()

  a = (a*10+7)%K



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

a = 7



for k in range(1,K+1):

  if a%K==0:

    print(k)

    exit()

  a = (10*a+7)%K



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

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

-for n in range(1, 1 + K): +for k in range(1, K + 1): -        print(n) +        print(k) -    a = (a * 10 + 7) % K +    a = (10 * a + 7) % K