K = int(input())
ans = '-1'
mod = 7%K
path = [mod]
for i in range(1,K+1):
  if mod == 0:
    ans = i
    break
  mod = (mod*10 + 7)%K
  path.append(mod)
  if mod == path[0]:
    ans = '-1'
    break
print(ans) K = int(input()) K int(input()) int input() input ans = '-1' ans '-1' mod = 7%K mod 7%K 7 K path = [mod] path [mod] mod for i in range(1,K+1):
  if mod == 0:
    ans = i
    break
  mod = (mod*10 + 7)%K
  path.append(mod)
  if mod == path[0]:
    ans = '-1'
    break i range(1,K+1) range 1 K+1 K 1 if mod == 0:
    ans = i
    break
   mod == 0 mod 0 ans = i ans i break mod = (mod*10 + 7)%K mod (mod*10 + 7)%K mod*10 + 7 mod*10 mod 10 7 K path.append(mod) path.append path append mod if mod == path[0]:
    ans = '-1'
    break mod == path[0] mod path[0] path 0 ans = '-1' ans '-1' break print(ans) print ans K = int(input()) int(input()) K ans = '-1' '-1' ans ans = i i ans mod = (mod*10 + 7)%K (mod*10 + 7)%K mod mod = 7%K 7%K mod path = [mod] [mod] path ans = '-1' '-1' ans
K = int(input())
ans = '-1'
mod = 7%K
path = [mod]
for i in range(1,K+1):
  if mod == 0:
    ans = i
    break
  mod = (mod*10 + 7)%K
  path.append(mod)
  if mod == path[0]:
    ans = '-1'
    break
print(ans)
