K = int(eval(input()))



for i in range(K):

    if i == 0:

        N= 7%K

    else:

        N = (10*N+7)%K

    if N == 0:

        print((i+1))

        break

else:

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



num = 7%K



for i in range(K):

  if num%K ==0:

    print((i+1))

    break

  else:

    num = (num*10 + 7)%K

    

else:

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

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

+num = 7 % K -    if i == 0: -        N = 7 % K -    else: -        N = (10 * N + 7) % K -    if N == 0: +    if num % K == 0: +    else: +        num = (num * 10 + 7) % K