K = int(input())
L = 0
if K % 7 == 0:
  L = 9*K//7
else:
  L = 9*K
  
t = 1
ans = -1
for i in range(1,L,1):
  t = t*10
  if t % L == 1:
    ans = i
    break
  t = t % L
print(ans) K = int(input()) K int(input()) int input() input L = 0 L 0 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 t = 1 t 1 ans = -1 ans -1 for i in range(1,L,1):
  t = t*10
  if t % L == 1:
    ans = i
    break
  t = t % L i range(1,L,1) range 1 L 1 t = t*10 t t*10 t 10 if t % L == 1:
    ans = i
    break
   t % L == 1 t % L t L 1 ans = i ans i break t = t % L t t % L t L print(ans) print ans t = 1 1 t t = t % L t % L t K = int(input()) int(input()) K L = 9*K//7 9*K//7 L L = 9*K 9*K L ans = -1 -1 ans L = 0 0 L t = t*10 t*10 t ans = i i ans
K = int(input())
L = 0
if K % 7 == 0:
  L = 9*K//7
else:
  L = 9*K
  
t = 1
ans = -1
for i in range(1,L,1):
  t = t*10
  if t % L == 1:
    ans = i
    break
  t = t % L
print(ans)