K = int(input())

if K % 2 == 0 or K % 5 == 0:
  print(-1)
else:
  if K % 7 == 0:
    L = 9 * K // 7
  else:
    L = 9 * K
  a = 10 % L
  check = False
  for i in range(L):
    a %= L
    if a == 1:
      print(i + 1)
      check = True
      break
    a *= 10
  if not check:
    print(-1) K = int(input()) K int(input()) int input() input if K % 2 == 0 or K % 5 == 0:
  print(-1)
else:
  if K % 7 == 0:
    L = 9 * K // 7
  else:
    L = 9 * K
  a = 10 % L
  check = False
  for i in range(L):
    a %= L
    if a == 1:
      print(i + 1)
      check = True
      break
    a *= 10
  if not check:
    print(-1) K % 2 == 0 or K % 5 == 0 K % 2 == 0 K % 2 K 2 0 K % 5 == 0 K % 5 K 5 0 print(-1) print -1 if K % 7 == 0:
    L = 9 * K // 7
  else:
    L = 9 * K
   K % 7 == 0 K % 7 K 7 0 L = 9 * K // 7 L 9 * K // 7 9 * K 9 K 7 L = 9 * K L 9 * K 9 K a = 10 % L a 10 % L 10 L check = False check False for i in range(L):
    a %= L
    if a == 1:
      print(i + 1)
      check = True
      break
    a *= 10
   i range(L) range L a %= L a L if a == 1:
      print(i + 1)
      check = True
      break
     a == 1 a 1 print(i + 1) print i + 1 i 1 check = True check True break a *= 10 a 10 if not check:
    print(-1) not check check print(-1) print -1 L = 9 * K 9 * K L a %= L L a check = True True check a = 10 % L 10 % L a check = False False check K = int(input()) int(input()) K L = 9 * K // 7 9 * K // 7 L a *= 10 10 a
K = int(input())

if K % 2 == 0 or K % 5 == 0:
  print(-1)
else:
  if K % 7 == 0:
    L = 9 * K // 7
  else:
    L = 9 * K
  a = 10 % L
  check = False
  for i in range(L):
    a %= L
    if a == 1:
      print(i + 1)
      check = True
      break
    a *= 10
  if not check:
    print(-1)