K = int(input())
r = 7 % K
ans = -2
for i in range(K):
   if r == 0:
      ans = i
      break
   r = 10*r + 7
   r = r % K
print(ans+1) K = int(input()) K int(input()) int input() input r = 7 % K r 7 % K 7 K ans = -2 ans -2 for i in range(K):
   if r == 0:
      ans = i
      break
   r = 10*r + 7
   r = r % K i range(K) range K if r == 0:
      ans = i
      break
    r == 0 r 0 ans = i ans i break r = 10*r + 7 r 10*r + 7 10*r 10 r 7 r = r % K r r % K r K print(ans+1) print ans+1 ans 1 ans = -2 -2 ans r = 10*r + 7 10*r + 7 r r = 7 % K 7 % K r r = r % K r % K r K = int(input()) int(input()) K ans = i i ans
K = int(input())
r = 7 % K
ans = -2
for i in range(K):
   if r == 0:
      ans = i
      break
   r = 10*r + 7
   r = r % K
print(ans+1)