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