Takahashi loves the number 7 and multiples of K.
Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)
If the sequence contains no multiples of K, print -1 instead.

-----Constraints-----
 - 1 \leq K \leq 10^6
 - K is an integer.

-----Input-----
Input is given from Standard Input in the following format:
K

-----Output-----
Print an integer representing the position of the first occurrence of a multiple of K. (For example, if the first occurrence is the fourth element of the sequence, print 4.)

-----Sample Input-----
101

-----Sample Output-----
4

None of 7, 77, and 777 is a multiple of 101, but 7777 is.

Difficulty: introductory

Starter code:

Solutions:
K = int(input())

a = [7] * (K + 1)
a[0] %= K
for i in range(1, K+1):
    a[i] = (10*a[i-1] + 7) % K

ans = [i+1 for i, ai in enumerate(a) if ai == 0]

if len(ans) > 0:
    print((ans[0]))
else:
    print((-1))


k = int(input())
aaa = [0] * k
aaa[0] = 7 % k
for i in range(1, k):
    aaa[i] = (aaa[i - 1] * 10 + 7) % k
ans = -1
for j in range(k):
    if aaa[j] == 0:
        ans = j + 1
        break
print(ans)


k = int(input())

if 7 % k == 0:
    print(1)
    return

a = [7 % k]
for i in range(2, k+1):
    aa = (10 % k) * a[-1] + a[0]
    a.append(aa % k)
    if a[-1] % k == 0:
        print(i)
        return

print(-1)

K = int(input())

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

def main(K):
    ans = -1
    if K%2==0 or K%5==0:
        return ans
    else:
        seven = 7
        for i in range(K):
            if seven % K == 0:
                ans = i + 1
                return ans
            seven = (seven * 10 + 7) % K

def __starting_point():
    K = int(input())
    ans = main(K)
    print(ans)



__starting_point()

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

K = int(input())

i = 7%K
se = set([i])
cnt = 1
while True:
  if i == 0:
    print(cnt)
    break
  cnt += 1
  i = (i*10 + 7)%K
  if i in se:
    print((-1))
    break
  else:
    se.add(i)


K = int(input())

frag = [0]*(K+1)
frag[1] = 7%K
for i in range(2,K+1):
   frag[i] = (frag[i-1] * 10 + 7) % K

for i in range(1,K+1):
    if frag[i] == 0:
        print(i)
        break
else:
    print(-1)

import sys
read = sys.stdin.read
#readlines = sys.stdin.readlines
from collections import defaultdict
def main():
    k = int(input())
    if k % 2 == 0:
        print((-1))
        return
    rems = defaultdict(int)
    n = 7 % k
    next_digit = 70 % k
    r = 1
    while True:
        if n == 0:
            print(r)
            return
        elif rems[n]:
            print((-1))
            return
        else:
            rems[n] = 1
            n += next_digit
            n = n % k
            next_digit = (next_digit * 10) % k
            r += 1
def __starting_point():
    main()

__starting_point()

k = int(input())
a = [0] * (10**6+1)
a[1] = 7 % k
for i in range(2, k+1):
    a[i] = (a[i-1]*10+7) % k
for i in range(1, k+1):
    if a[i] == 0:
        print(i)
        break
else:
    print((-1))


k = int(input())
ans = -1
sm = 7
i = 1
if k % 2 == 0 or k % 5 == 0:
    ans = -1
elif sm % k == 0:
    ans = 1
else:
    while True:
        sm = (sm * 10 + 7) % k
        if sm == 0:
            ans = i + 1
            break
        i += 1
print(ans)


K = int(input())
if K%2 == 0 or K%5 == 0:
    print(-1)
    return
r = 7%K
ans = 1
while r != 0:
    r = (r*10 + 7)%K
    ans += 1
print(ans)

k = int(input())

num = 7 % k
ans = 1
mod = [0 for _ in range(k)]
mod[num] = 1
while(num):
    num = (num * 10 + 7) % k
    if mod[num] > 0:
        ans = -1
        break
    ans += 1
    mod[num] += 1

print(ans)


N = int(input())
ops = 0
if N%2 == 0 or N%5 == 0:
    ops = 1

else:
    if N%7 == 0:
        L = 9*N//7
    
    else:
        L = 9*N

    ch = 10%L
    for i in range(1, N+1):
        if ch == 1:
            ans = i
            break

        ch = (10*ch)%L

        if i == N+1:
            ops = 1

if ops:
    print((-1))

else:
    print(ans)




K = int(input())

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

def main():
	K = int(input())
	rn = [0]
	r = [0] * K
	for i in range(K):
		ri = (rn[-1] * 10 + 7) % K
		if ri == 0:
			print(i + 1)
			return 0
		elif r[ri] == 0:
			r[ri] = 1
			rn.append(ri)
		elif r[ri] == 1:
			print(-1)
			return 0

main()

k = int(input())
a = [0] * (10 ** 6+1)
a[0] = 7 % k
for i in range(k):
    a[i+1] = (a[i] * 10 + 7) % k
for i in range(k):
    if a[i] == 0:
        print(i+1)
        return
print(-1)

k = int(input())

def cal(k):
    n = 7
    for i in range(1,10000000):
        if n % k == 0:
            return i
        else:
            n = (n *10 + 7) % k
    return -1

print(cal(k))

k = int(input())
cnt = 1
mod = 7

for i in range(k):
    if mod%k == 0:
        break
    cnt += 1
    mod = (mod*10+7)%k

if mod%k == 0:
    print(cnt)
else:
    print(-1)

k = int(input())

if k%7==0:
    l = 9*(k//7)
elif k%5==0 or k%2==0:
    print(-1)
    return
else:
    l = 9*k

n = 10
for i in range(1, l):
    if n % l == 1:
        print(i)
        return
    n = 10*(n%l)

print(-1)

K = int(input())
mod = 7 % K
ans = -1

for k in range(K):
    if mod == 0:
        ans = k + 1
        break
    mod = (mod * 10 + 7) % K

print(ans)

k=int(input())
a=0
c=0
t=1
for i in range(k):
  a=(a*10+7)%k
  c+=1
  if a==0:
    t=0
    print(c)
    break
if t:
  print((-1))


k = int(input())


if k % 2 == 0 or k % 5 == 0:
    print(-1)
else:
    exc = 0
    for i in range(1, 10 ** 8):
        exc = exc * 10 + 7
        exc = exc % k
        if exc % k == 0:
            ans = i
            break
    print(ans)

def main():
  K = int(input())
  ans = False
  if K % 2 == 0:
    print(-1)
    return
  cnt = 7 % K
  for i in range(1, K+1):
    if cnt == 0:
      ans = True
      print(i)
      return
    cnt = (10 * cnt + 7) % K
  if ans == False:
    print(-1)
    return
main()

k = int(input())
a = 7
for i in range(k+1):
  b = a%k
  if b == 0:
    print(i+1)
    return
  a = b*10+7
print('-1')


k = int(input())
r = 7 % k
for i in range(k):
    if r == 0:
        print(i+1)
        return
    r = (r * 10 + 7) % k
print(-1)

k=int(input())

if k%2==0 or k%5==0:
  print(-1)
  return

ans=1
num=7
while num%k!=0:
  num=10*num+7
  num%=k
  ans+=1

print(ans)

mod = int(input())
a = {}
b = int(0)
flag = int(0)
ans = int(0)
for i in range(mod):
  b = b * 10 + 7
  b = b % mod
  if b == 0:
    flag = 1
    ans = int(i) + 1
    break
  else:
    pass

if flag == 1:
  print(ans)
else:
  print("-1")

k=int(input())
rem=0

for i in range(k):
    rem=(10*rem+7)%k
    if rem==0:
        print(i+1)

        break
    if i==k-1:
        print(-1)

K = int(input())
mod = 7
for i in range(K):
    mod = mod % K
    if(mod == 0):
        print(i+1)
        return
    else:
        mod *=10
        mod += 7
print("-1")

def ans(k):
    arry = [None] * k
    arry[0] = 7 % k
    for i in range(k - 1):
        arry[i+1] = (10*arry[i]+7) % k

    for i in range(k):
        if arry[i] == 0:
            return i+1

    return -1


K = int(input())
print(ans(K))

K = int(input())

a = 7
for i in range(1, K+1):
    b = a%K
    if b == 0:
        print(i)
        return
    a = b*10+7
print(-1)

#                               #
    # author : samars_diary #
    # 17-09-2020 │ 16:21:14 #
#                               #

import sys, os.path

#if(os.path.exists('input.txt')):
    #sys.stdin = open('input.txt',"r")
    #sys.stdout = open('output.txt',"w")

sys.setrecursionlimit(10 ** 5)

def mod(): return 10**9+7
def i(): return sys.stdin.readline().strip()
def ii(): return int(sys.stdin.readline())
def li(): return list(sys.stdin.readline().strip())
def mii(): return map(int, sys.stdin.readline().split())
def lii(): return list(map(int, sys.stdin.readline().strip().split()))

#print=sys.stdout.write

def solve():
    a=ii()
    val=7%a
    for i in range(1,10**7):
        if val==0:
            print(i)
            return
        val=(val*10+7)%a
    print(-1)
for _ in range(1):
    solve()

#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
# mod = 9982443453
# mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
k = I()
i = 0
a = 0
while i < k:
    a = (a * 10 + 7)%k
    if a == 0:
        print((i+1))
        return
    i += 1
print((-1))


import sys

k = int(input())
r = 0


for i in range(1, k+10):
	r *= 10
	r += 7
	r %= k
	if r == 0:
		print(i)
		return

print('-1')

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

print(ans)

k=int(input())
a=0
cnt=-1
for i in range(1,k+1):
  a=(10*a+7)%k
  if a==0:
    cnt=i
    break
print(cnt)

K = int(input())

mod = 7
cnt = 0

for i in range(K):
    if mod % K == 0:
        cnt += 1
        break
    else:
        cnt += 1
        mod = (mod * 10 + 7) % K
if mod % K == 0:
    print(cnt)
else:
    print((-1))


K = int(input())

def calc(K):
    if K % 2 == 0:
        return -1
    seven =0
    for i in range(1,10**6):
        seven *= 10
        seven += 7
        seven %= K
        if seven == 0 :
            return i
    return -1

print((calc(K)))




k = int(input()) # 101, 999983
a = 7
for i in range(k+1):
  if a % k ==0:
    print((i + 1))
    break
  else:
    a = (a * 10 + 7) % k
else:
  print((-1))


k=int(input())

if k%2==0:
  print(-1)
  return
  
if k%5==0:
  print(-1)
  return
  
if k%7==0:
  k=k//7

# m(r)=10**0+10**1+...+10**(r-1)
# 10*m(r)=10**1+10**2+...+10**r
# 9*m(r)=10**r-10**0
# m(r)=(10**r-1)/9

# m(r)%n=(10**r-1)/9%k=0
# (10**r-1)%(9*k)=0

# 10**r%(9*k)=1
# 10**r%(9*k)=(10**(r-1)%(9*k))*10%(9*k)=1

r=1
m=10
while True:
  m%=(9*k)
  #print(r,m)
  if m==1:
    print(r)
    return
  r+=1
  m*=10

k = int(input())
t = 7
t %= k

for i in range(k+1):
    if t == 0:
        print((i+1))
        break
    t = (t*10+7) % k
else:
    print((-1))


import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


k = I()
ans = -1
a = [0] * (k+1)
a[1] = 7 % k
for i in range(2, k+1):
    a[i] = (a[i-1]*10 + 7) % k

for i in range(1, k+1):
    if a[i] == 0:
        print(i)
        return
print((-1))


def calc(k):
    cur = 7 % k
    for i in range(1, k + 1):
        if cur == 0:
            return i
        else:
            cur *= 10
            cur += 7
            cur %= k
    return -1


k = int(input())
print(calc(k))

import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

k = int(input())

tmp = 7
res = 1

for i in range(k):
    tmp %= k
    if tmp == 0:
        break
    tmp = tmp * 10 + 7
    res += 1
if res > k and tmp > 0:
    res = -1

print(res)


k = int(input())
kkk = [0] * k
kkk[0] = 7 % k
ans = -1
for i in range(1, k):
    kkk[i] = (kkk[i - 1] * 10 + 7) % k
for j in range(k):
    if kkk[j] == 0:
        ans = j + 1
        break
print(ans)


k = int(input())
x = 7%k
ans = 1
for i in range(k):
    if x == 0:
        print(ans)
        break
    x = (10*x+7) % k
    ans += 1
else:
    print(-1)

K=int(input())
wa=0
kake=1
for i in range(1,K+2):
  if i!=1:
    kake=kake*10%K
  wa+=7*kake
  if wa%K==0:
    print(i)
    return
print(-1)

K = int(input())

ans = -1

r = 7 % K
SUM = r
if SUM % K == 0:
    ans = 1
else:
    for i in range(1, K):
        r = (r * 10) % K
        SUM += r
        if SUM % K == 0:
            ans = i + 1
            break
    
print(ans)

import sys
k = int(input())

a = 7
a = a % k
for i in range(1000000):
  if a ==0:
    print((i+1))
    return
  else:
    a = 10*a+7
    a = a % k

print("-1")


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


k = int(input())
ans = -1
mod = 7%k

for i in range(k):
    if mod == 0:
        ans = i+1
        break
    mod = (mod*10+7)%k
print(ans)


k=int(input())
k *= 9
amari = 63
for i in range(1, 10 ** 6 + 1):
  amari %= k
  if amari == 0:
    print(i)
    break
  else:
    amari = amari * 10 + 63
else:
  print(-1)

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

K = int(input())

def calc(K):
    if K % 2 == 0:
        return -1
    seven =0
    for i in range(1,K+1):
        seven *= 10
        seven += 7
        seven %= K
        if seven == 0 :
            return i
    return -1

print(calc(K))

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

K = int(input())

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

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

def main():
    K = int(input())

    if K % 2 == 0 or K % 5 == 0:
        print((-1))
        return

    r = 7 % K
    n = 1
    while r != 0:
        r = (10 * r + 7) % K
        n += 1
    print(n)
    return


def __starting_point():
    main()

__starting_point()

k = int(input())
a = 7
if k == 1 or k == 7 :
    print((1))
    return

for i in range(k):
    a *= 10
    a += 7
    a %= k
    if a == 0 :
        print((i+2))
        return
print((-1))


a = int(input())
temp = 7
mod = temp % a
i = 1

if a % 2 == 0 or a % 5 == 0:
  print((-1))
  return

while mod != 0:
  mod = (mod * 10 + 7) % a
  i+=1

print(i)


K = int(input())
A = 7
count = 1

for i in range(K):
  if A%K == 0:
    print(count)
    break
  count += 1
  A = (10*A + 7)%K
else:
  print("-1")

k = int(input())

a = 0
for i in range(k):
  a = (a * 10 + 7) % k
  if a == 0:
    print(i + 1)
    return
print(-1)

k = int(input())
seven = 7
ans = -1

for i in range(1,k+1):
    seven %= k
    if seven  == 0:
        ans = i
        break
    else:
        seven = seven * 10 + 7

print(ans)

# author:  Taichicchi
# created: 19.09.2020 00:06:44

import sys

K = int(input())

a = 7 % K

for k in range(K + 2):
    if a == 0:
        print((k + 1))
        break
    a = (a * 10 + 7) % K
else:
    print((-1))


import sys
K = int(input())
a = 7%K

if a==0:
    print(1)
    return

for i in range(1,K):
    a = (10 * a + 7)%K
    if a == 0:
        print(i+1)
        return

print(-1)


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

k=int(input())

if k%2==0 or k%5==0:
  print(-1); return

cnt=num=0
while 1:
  num+=7*pow(10,cnt,k)
  num%=k
  cnt+=1
  if num==0:
    break
print(cnt)

K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
    return

start = j = 7 % K
count = 1

#無限ループ
while True:
    #0の時
    if j == 0:
        print(count)
        return
        
    j = 10 * j + 7
    j = j % K
    count += 1
    
    #同じ数のループしているかチェック
    if j == start:
        print(-1)
        return

k = int(input())
#x, k, d = map(int, input().split())
#al = list(map(int, input().split()))
#al=[list(input()) for i in range(n)]
ans = -1
ai = 0
for i in range(1, k+1):
    ai = (ai*10+7) % k
    if ai == 0:
        ans = i
        break
print(ans)


def main():
    K = int(input())

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


def __starting_point():
    main()

__starting_point()

def calc(n):
    mod = 0
    for i in range(1, n+1):
        mod = mod *10
        mod = mod + 7
        mod = mod % n
        if mod == 0:
            return i
    return -1

k = int(input())
print(calc(k))

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

k = int(input())
count = 0
n = 0
for i in range(k):
    n = (10*n + 7)%k
    if n % k == 0:
        print(i+1)
        count+=1
        break
if count == 0:
    print(-1)

K = int(input())
R = 0
for i in range(1, K + 10):
  R *= 10
  R += 7
  R %= K
  if R == 0:
    print(i)
    import sys
    return
print((-1))


import sys
#import time
from collections import deque, Counter, defaultdict
#from fractions import gcd
import bisect
import heapq
#import math
import itertools
import numpy as np
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))

k = ri()
reses=[]
cnt = 1
tmp = 7
for i in range(k+1):
    res = tmp % k
    if res==0:
        print(cnt)
        return
    tmp = res * 10 + 7
    cnt += 1
print(-1)

K=int(input())
wa=0
kake=1
for i in range(1,K+1):
  if i!=1:
    kake=kake*10%K
  wa+=7*kake
  if wa%K==0:
    print(i)
    return
print(-1)

K = int(input())
if K%2 == 0 or K%5 == 0:
    ans = -1
else:
    a = 1
    r = 7
    d = 70
    while True:
        if r%K ==0:
            ans = a
            break
        else:
            r, d, a = (r+d)%K, d*10%K, a+1
print(ans)

k = int(input())
start = 7 % k
ans = start
con = 1

if k % 2 == 0 or k % 5 == 0:
  print("-1")
  return
while True:
  if ans == 0:
    print(con)
    break
  else:
    con += 1
    ans = ans * 10 + 7
    ans = ans % k
    if ans == start:
      print("-1")
      break


from time import time

K = int(input())
t = time()

i = 1
n = 7%K
m = 10%K
while time()-t < 1.95:
    if n == 0:
        print(i)
        break
    n += 7*m
    n %= K
    m = m*10%K
    i += 1
else:
    print(-1)

k=int(input())

if k%2==0 or k%5==0:
  print((-1))
else:
  s=1
  a=7
  while a%k!=0:
    a=(10*a+7)%k
    s+=1
  print(s)


K=int(input())
t=7
for i in range(10**6):
  if t%K==0:
    print(i+1)
    return
  t=(t*10+7)%K
print(-1)

def c174(k):

    ans = -1
    sebun = 7

    for i in range(k):
        if sebun % k == 0:
            ans = i + 1
            return ans
        sebun = (sebun%k) * 10 + 7
    return ans

def main():
    k = int(input())
    print(c174(k))

def __starting_point():
    main()
__starting_point()

K = int(input())

MOD = 7%K
if MOD == 0:
    print(1)
    return

for i in range(2, K+1):
    MOD = (MOD * 10 + 7) % K
    if MOD == 0:
        print(i)
        return

print(-1)

k = int(input())
cnt = 1
mod = 7

for _ in range(k):
    if mod%k == 0:
        break
    cnt += 1
    mod = (mod*10+7)%k

if mod%k == 0:
    print(cnt)
else:
    print(-1)

k=int(input())
a,bk=7,7
for i in range(1,k+1):
  if i!=1:
    bk=bk*10%k
    a+=bk
  a%=k
  if a==0:
    print(i)
    return
print(-1)

k = int(input())
ans = -1
sm = 7
i = 1
if k % 2 == 0 or k % 5 == 0:
    ans = -1
elif sm % k == 0:
    ans = 1
else:
    for i in range(1, k):
        sm = (sm * 10 + 7) % k
        if sm == 0:
            ans = i + 1
            break
        i += 1
print(ans)


K = int(input())
if K%2 == 0 or K%5 == 0:
    print(-1)
else:
    a = 7
    i = 0
    while True:
        if a % K ==0:
            print(i + 1)
            break
        else:
            a, i = (a * 10 + 7) % K, i+1

K = int(input())

seven = [0]*K
seven[0] = 7%K
for i in range(1,K):
    seven[i] = (10*seven[i-1]+7)%K


for i in range(K):
    if seven[i] == 0:
        print(i+1)
        return
print(-1)

def main():
    k = int(input())
    li = 7
    
    if k % 2 == 0:
        print(-1)
        return
    
    for i in range(k):
        if li % k == 0:
            print(i+1)
            break
        li = (li * 10 + 7) % k
    else:
        print(-1)
    
    
    
def __starting_point():
    main()
__starting_point()

K = int(input())

a=[7 % K]
for i in range(1, K):
  a.append((10*a[i-1] + 7) % K)

flag = False
for i in range(len(a)):
  if a[i] == 0:
    print((i+1))
    flag = True
    break
if not flag:
  print((-1))


#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

k = int(input())

t = 7
for i in range(k):
    t = t % k
    if t == 0:
        print((i + 1))
        return
    else:
        t = t * 10 + 7
print((-1))


k = int(input())
n = 7
n = n%k
j = 0
i = 1
if k % 2 == 0 or k % 5 == 0:
    print(-1)
    return
if n == 0:
    print(i)
    return
while n != 0:
    j = n
    n = (n*10 + 7) % k 
    if j == n:
        print(-1)
        return
    i += 1

print(i)

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

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


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

k = int(input())

if 7 % k == 0:
    print((1))
else:
    a = []
    a.append(7 % k)
    t = 0
    for i in range(2, k+1):
        x = (10 * a[i - 2] + 7) % k
        if x == 0:
            print(i)
            break
        else:
            a.append(x)
            t += 1
    if t == k - 1:
        print((-1))