Problem:
 Score : 300 points    Problem Statement 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 1 101      Sample Output 1 4  None of 7 , 77 , and 777 is a multiple of 101 , but 7777 is.       Sample Input 2 2      Sample Output 2 -1  All elements in the sequence are odd numbers; there are no multiples of 2 .       Sample Input 3 999983      Sample Output 3 999982

Solution (Python):
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy


import heapq
sys.setrecursionlimit(10**6)

K = int(input())

i = 7
s = set()
count = 1

while True:
    j = i % K
    if j == 0:
        print(count)
        sys.exit()

    if j in s:
        print(-1)
        sys.exit()

    s.add(j)
    i = j*10 + 7
    count += 1

Solution (Python):
k = int(input())

val = 7
cnt = 1

while cnt <= 10 ** 6:
  val %= k
  if val % k == 0:
    print(cnt)
    exit()
  cnt += 1
  val = val * 10 + 7

print(-1)

Solution (Python):
K = int(input())
remainder_set = set()
sequence = 7
i = 1
for i in range(K):
    remainder = sequence%K
    
    if remainder == 0:
        print(i+1)
        break
    else:
        if remainder in remainder_set:
            print(-1)
            break
        else:
            i += 1
            remainder_set.add(remainder)
            sequence = remainder*10 + 7

Solution (Python):
K = int(input())
count = 1
mod = 7
answer = -1

for i in range(K):
    if mod % K == 0:
        answer = count
        break
    count += 1
    mod = (mod * 10 + 7) % K

print(answer)

Solution (Python):
K = int(input())
se = set()
x = 7 % K
cnt = 1
while True:
    if x == 0:
        print(cnt)
        exit()
    if x in se:
        print(-1)
        exit()
    se.add(x)
    x = (10 * x + 7) % K
    cnt += 1

Solution (Python):
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]

def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  k=I()
  st=7
  if k==1 or k==7:
    return 1
  for i in range(1,1000001):
    st+=7*pow(10,i,k)
    st%=k
    if st==0:
      return i+1

  return -1


print(main())

Solution (Python):
K = int(input())

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

ans = 10
kou = -1
for i in range(1, 10**6):
    ans %= L
    if ans == 1:
        kou = i
        break
    else:
        ans *= 10

print(kou)

Solution (Python):

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

Solution (Python):

K = int(input())
count = 1
tmp = 7
while count < 10**6+1:
    tmp %= K
    if tmp == 0:
        print(count)
        exit()
    tmp = tmp*10 + 7

    count += 1

print(-1)

Solution (Python):
K=int(input())

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

if L%2==0 or L%5==0:
    print(-1)
    exit()

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

print(ans)

Solution (Python):
import sys

K = int(input())

count = 1
ans = -1
remainder = 0
check = [False] * (K + 1)

while True:
    remainder = (remainder * 10 + 7) % K
    if remainder == 0:
        ans = count
        break

    if check[remainder]:
        break

    check[remainder] = True
    count += 1

print(ans)

Solution (Python):
n=int(input())
mod=7
for i in range(n):
  if mod%n==0:
    print(i+1)
    exit()
  mod=(mod*10+7)  %n
print(-1)

Solution (Python):


import sys
input=sys.stdin.readline

def judge(k):
    if k%2==0 or k%5==0:
        print(-1)
    else:
        tmp=0
        for i in range(10**6):
            tmp+=7
            tmp%=k
            if tmp==0:
                print(i+1)
                break
            else:
                tmp*=10

k=int(input())
judge(k)

Solution (Python):
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)

Solution (Python):
N = int(input())
if N%2==0 or N%5==0:
  print(-1)
  
else:
  j = 1 
  mod = 7%N
  flag=True
  while flag:
    if mod==0:
      print(j)
      break
    elif mod>0:
      n = mod*10+7
      mod = n%N
      j+=1

Solution (Python):
K = int(input())
remainder = 0
ans = -1
 
if K % 2 == 0 or K % 5 == 0:
    ans = -1
else:
    for n in range(1,10**6):
      remainder = (remainder*10 + 7) % K
      if remainder == 0:
          ans = n
          break
      if n == 10**6-1:
          ans = -1
print(ans)

Solution (Python):
K = int(input())

ai =0
ans = 0

l = set()

if K %2 == 0:
    ans = -1
else:
    for i in range(K):
        ai = (ai * 10 + 7) % K
        if ai == 0:
            ans = i+1
            break
        else:
            if ai in l:
                ans = -1
                break
            else:
                l.add(ai)
print(ans)

Solution (Python):
s, k = '', int(input())
for i in range(k):
    s += '7'
    s = str(int(s)%k)
    if not int(s): print(i+1); break
else: print(-1)

Solution (Python):

k=int(input())


if k%2==0 or k%5==0:
  i=-1
else:
  l=9*k if k%7 else 9*k//7
  i,n=1,10
  while n%l!=1:
    n=n*10%l
    i+=1

print(i)

Solution (Python):
k = int(input())
if k % 2 and k % 5:
  i = 7
  for t in range(10000000):
    i %= k
    if i == 0:
      print(t+1)
      quit()
    i *= 10
    i += 7
else:
  print(-1)

Solution (Python):
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
    n = 1
    P = 10 % L
    while True:
        if P == 1:
            print(n)
            break
        n += 1
        P = (10 * P) % L

Solution (Python):
N = int(input())
a=0
flag=0
for i in range(1,N+1):
    a=(a*10+7)%N   
    if a==0:
        print(i)
        flag=1
        break

if flag==0:
    print(-1)

Solution (Python):
import sys

if sys.argv[-1] == "ONLINE_JUDGE":
    from numba.pycc import CC
    cc = CC("solve")

    @cc.export('solve', 'i8(i8)')
    def f(k):
        a = 7 % k
        for i in range(k):
            if a == 0:
                return i + 1
            a = (a * 10 + 7) % k
        else:
            return -1
    cc.compile()
    exit(0)

from solve import solve
print(solve(int(input())))

Solution (Python):
from numba import njit,prange
@njit('i8(i8)',cache=True)
def f(k):
    a = 7%k
    for i in prange(k):
        if a == 0:
            return i+1
        a = (a*10+7)%k
    else:
        return -1
k = int(input())
print(f(k))

Solution (Python):
from numba import njit
@njit(cache=True)
def f(k):
    a = 7%k
    for i in range(k):
        if a == 0:
            print(i+1)
            break
        a = (a*10+7)%k
    else:
        print(-1)
k = int(input())
f(k)

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

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

Solution (Python):
import sys
k=int(input())
if k%2==0 or k%5==0:
    print(-1)
    sys.exit()
else:
    if k%7==0:
        l=(k//7)*9
    else:
        l=9*k
        
    j = 1
    n = 10
    rem = n%l
    while True:
        if rem == 1:
            print(j)
            sys.exit()
        rem = (rem*10)%l
        j+=1

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    K = int(input())
    x = 0
    i = 0
    if K % 2 == 0 or K % 5 ==  0:
        print(-1)
        exit()
    
    while True:
        x = (x * 10 + 7) % K
        i += 1
        if x == 0:
            print(i)
            break


    

if __name__ == "__main__":
    main()

Solution (Python):






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

Solution (Python):
k = int(input())
ans = 0
mod = 7
flag = 0
for i in range(10 ** 6 + 1):
    ans += 1
    if mod % k == 0:
        flag = 1
        break
    else:
        mod = (mod % k) * 10 + 7

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

Solution (Python):
k=int(input())

if k%7==0:
    l=9*k//7
else:
    l=9*k

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

Solution (Python):
import math
K=int(input())

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

if L%2==0 or L%5==0:
    ans=-1
else:
    r=10%L
    for i in range(1,10**6+1):
        if r==1:
            ans=i
            break
        else:
            r=10*r%L
print(ans)

Solution (Python):
k=int(input())
if k==7:
    print(1)
    exit()
if k%7==0:
    k//=7

x=9
for i in range(1,9000000):
    if x%(9*k)==0:
        print(i)
        exit()
    x%=(9*k)
    x*=10
    x+=9
print(-1)

Solution (Python):
k = int(input())

if k % 2 == 0 or k % 5 == 0:
    ans = -1

else:
    if k % 7 == 0:
        L = k * 9 // 7
    
    else:
        L = k * 9
        
    amari = 10 % L
        
    for i in range(1,10**6+1):
        if amari == 1:
            ans = i
            break
        
        amari = (amari * 10) % L
        
print(ans)

Solution (Python):
k = int(input())
x = 7 % k
ans = 1
for i in range(k):
    if x == 0:
        print(ans)
        exit()
    ans += 1
    x = (x * 10 + 7) % k

print(-1)

Solution (Python):
K = int(input())
now = 7

for i in range(10**7):
    if now%K==0:
        print(i+1)
        exit()
    
    now = (10*now+7)%K

print(-1)

Solution (Python):
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

k = INT()
x = 0
for i in range(k):
    x = ( x * 10 + 7 ) % k
    if x % k == 0:
        print(i+1)
        exit()
print(-1)

Solution (Python):
k=int(input())
s={7%k}
a=7%k
n=1
flag=True
while not {0}<=s:
    a=(a*10+7)%k
    beforelen=len(s)
    s.add(a)
    if len(s)==beforelen:
        flag=False
        break
    n+=1
print(n if flag else -1)

Solution (Python):
k = int(input())
i = 0
t = 1
k = k*9

if k%7 == 0 :
    k = k/7
if k%2 == 0 or k%5 == 0:
    i = -1
else:
    while(True):
        t *= 10
        i += 1
        t = t%k
        if t==1:
            break
    
print(i)

Solution (Python):
K = int(input())
N = 10
a = 0
l = 9*K
if(K==7 or K==1):
  a+=1
  print(1)
else:
  for i in range(1,10**6):
    N = (10*N)%l
    if (N*7-7)%l==0:
      print(i+1)
      a +=1
      break
  if(a == 0):
    print(-1)

Solution (Python):

import sys

rl = sys.stdin.buffer.readline
INF = sys.maxsize


K = int(rl())

def solve(K):
  L = ((9 * K) // 7) if K % 7 == 0 else (9 * K)
  if L % 2 == 0 or L % 5 == 0:
    return -1
  a = 1 % L
  for i in range(L):
    a = (a * 10) % L
    if a == 1:
      return i + 1

  return -1

print(solve(K))

Solution (Python):
k = int(input())

mod = 7

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

if mod % k == 0:
    ans = i + 1
else:
    ans = -1

print(ans)

Solution (Python):
k=int(input())
flag=True
seq=7
"""
これは階乗を含むのでO(klogk)で重い
for i in range(1,k+1):
  if (7*(10**i-1)//9) % k==0:
    print(i)
    flag=False
    break
"""
for i in range(1,k+1):
  if seq%k==0:
    print(i)
    flag=False
    break
  seq=(seq*10+7)%k  
  
if flag:
  print(-1)

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

Solution (Python):
k = int(input())
ans = -1
x = 7 % k
if not k%2 == 0:
    for i in range(1, k+1):
        if x == 0:
            ans = i
            break
        x = (x * 10 + 7) % k


print(ans)

Solution (Python):
K = int(input())
val = 7
for i in range(1,2000000):
    val %= K
    if val == 0:
        print(i)
        exit()
    else:
        val = val*10+7
print(-1)

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

Solution (Python):
K = int(input())

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

i = 0
ai = 0
while True:
    ai = (ai * 10 + 7) % K
    i += 1
    if ai == 0:
        break
print(i)

Solution (Python):
K = int(input())
remain = 0
i = 0

answer = -1

for i in range(1, K+5):
    number = remain*10 + 7

    remain = number % K

    if remain == 0:
        answer = i
        break

print(answer)

Solution (Python):
K = int(input())

n = 1
x = 7


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


while 1:
  if x % K == 0:
    print( n )
    break
  x = (x * 10 + 7) % K
  n += 1

Solution (Python):
def solve():
    n = int(input())
    lim = 2000000
    s = 0
    for i in range(lim):
        s *= 10
        s += 7
        s %= n
        if s == 0:
            print(i + 1)
            exit()
    print(-1)

solve()

Solution (Python):
k = int(input())
target = 7; ans = -1
if not k % 2== 0:
    
    for i in range(1, k + 10):
        if target % k == 0:
            ans = i
            break
        target = (target * 10 + 7) % k
 
print(ans)

Solution (Python):
N = int(input())
if N % 7:
    L = 9*N
else:
    L = 9*N//7
num = 1
if L % 2 and L % 5:
    i = 1
    while i <= L:
        num = (num*10) % L
        if num == 1:
            print(i)
            break

        else:

            i += 1

else:
    print(-1)

Solution (Python):

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

    print(-1)


if __name__ == "__main__":
    resolve()

Solution (Python):
K = int(input())
i = 1
ret = -1
if K % 5 != 0 and K % 2 != 0:
  N = 10
  if K % 7 == 0:
    L = K * 9 // 7
  else:
    L = K * 9
  while True:
    if N % L == 1:
      ret = i
      break
    N = (N * 10 )% L
    i += 1
print(ret)

Solution (Python):
k = int(input())
tmp = 7
ans = 1
while tmp % k != 0:
    tmp = (tmp % k) * 10 + 7
    ans += 1
    if ans > k:
        ans = -1
        break
print(ans)

Solution (Python):
k = int(input())
if k % 7 == 0: k = k // 7
tmp = 1
ans = 1
while tmp % k != 0:
    tmp = (tmp % k) * 10 + 1
    ans += 1
    if ans > k:
        ans = -1
        break
print(ans)

Solution (Python):
k = int(input())
x = 1

if k%7 != 0:
    mod = 9*k
else:
    mod = 9*k//7

for i in range(10**6):
    x = x*10%mod
    if x == 1:
        print(i + 1)
        exit()

print(-1)

Solution (Python):

K = int(input())
if K % 7 == 0 :
    L = int( 9 * K / 7 )
else:
    L = 9 * K
X = 0
kekka = 1
total = -1
if L % 2 == 1:
    if L % 5 != 0:
        for i in range(L): 
            kekka = kekka * 10 % L
            if kekka == 1:
                total = i+1
                break

print(total)

Solution (Python):
K = int(input())
num = 7
ans = -1

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




print(ans)

Solution (Python):
K = int(input())
s = set()
x = 7%K
ans = 1

for i in range(K):
  if x == 0:
    break
  s.add(x)
  x=(x*10+7)%K
  ans+=1
  if x in s:
    ans=-1
    break

print(ans)

Solution (Python):
K = int(input())

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

ans = 0
ai = 0
while True:
    ai = (ai * 10 + 7) % K
    ans += 1
    if ai % K == 0:
        print(ans)
        exit()

Solution (Python):
K=int(input())
n=0
an=0
for i in range(K+10):
    n+=1
    an=(10*an+7)%K
    if an==0:
        print(n)
        exit()
print(-1)

Solution (Python):


k = int(input())
n = 0 

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

print(-1)

Solution (Python):
num = int(7)

ipt = input()
ipt = int(ipt)

res = 1
ok = False
while res < 1000000:
    if num % ipt==0:
        print(res)
        ok = True
        break
    else:
        num = num % ipt
        res = res + 1
        num = num*10 +7

if ok == False:
    print(-1)

Solution (Python):
num = int(7)

ipt = input()
ipt = int(ipt)

res = 1
ok = False
while res < 1000000:
    if num % ipt==0:
        print(res)
        ok = True
        break
    else:
        num = num % ipt
        res = res + 1
        num = num*10 +7

if ok == False:
    print(-1)

Solution (Python):

def main():
    import sys

    input = sys.stdin.readline

    K = int(input())

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


if __name__ == "__main__":
    main()

Solution (Python):
K = int(input())

S = set()
ans = 1
x = 7 % K
while True:
    if x in S:
        ans = -1
        break
    if x == 0:
        break
    ans += 1
    S.add(x)
    x = ((10 * x) % K + 7 % K ) % K

print(ans)

Solution (Python):
K = int(input())

if K%7 == 0:
  L = 9*K/7
else:
  L = 9*K
s = 1

for i in range(1, 9*(10**6)+1):
  s = s*10%L
  if s == 1:
    print(i)
    exit()

print("-1")

Solution (Python):
K=int(input())
result=-1
if K%2!=0 and K%5!=0:
  a=0
  b=7
  for i in range(K):
    a+=b
    a=a%K
    b=(b*10)%K
    if a==0:
      result=i+1
      break
      
print(result)

Solution (Python):
cnt = 1
mod = 7
k = int(input())
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)

Solution (Python):
cnt = 1
mod = 7
k = int(input())
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)

Solution (Python):



def solve(n):
    if n % 7 == 0:
        n //= 7

    if n % 2 == 0 or n % 5 == 0:
        return -1

    
    
    
    n9 = n * 9
    d = 10 % n9
    for i in range(n9):
        if d == 1:
            return i + 1
        d = (10 * d) % n9
    raise RuntimeError()


def main(istr, ostr):
    (k,) = list(map(int, istr.readline().strip().split()))
    result = solve(k)
    print(result, file=ostr)


if __name__ == "__main__":
    import sys

    main(sys.stdin, sys.stdout)

Solution (Python):

def solve():
	n=int(input())
	if n%2==0 or n%5==0:
		print(-1)
		return 
	ans=1
	p=7%n
	while(p!=0):
		p=(p*10+7)%n
		ans+=1
	print(ans)
if __name__ == "__main__":
	
	
	solve()

Solution (Python):
k = int(input())
m = 7%k

for i in range(1, 10**6+1):
    if m == 0:
        print(i)
        exit()
    else:
        m = (10 * m + 7) % k

print(-1)

Solution (Python):
K = int(input())
n = 7%K
r = 1
for i in range(10**6+5):
    if n==0:
        print(i+1)
        exit()
    r *= 10
    n += r*7
    r %= K
    n %= K
print(-1)

Solution (Python):
k = int(input())
ans = 7%k

for i in range(1, 10**6 + 1):
  if ans%k == 0:
    print(i)
    exit()
  else:
    ans = (ans*10 + 7)%k
print(-1)

Solution (Python):
k=int(input())
num=7%k
for i in range(1, 10**7+1):
    if num%k==0:
        print(i)
        exit()
    else:
        num=(num*10+7)%k
print(-1)

Solution (Python):
k=int(input())
num=7%k
for i in range(1, 10**6+2):
    if num%k==0:
        print(i)
        exit()
    else:
        num=(num*10+7)%k
print(-1)

Solution (Python):
k=int(input())
num=7%k
for i in range(1, 10**6+1):
    if num%k==0:
        print(i)
        exit()
    else:
        num=(10*num+7)%k
print(-1)

Solution (Python):
K = int(input())
n = 0
for i in range(K+1):
    n = n*10+7
    if n % K == 0:
        print(i+1)
        exit()
    n %= K
print(-1)

Solution (Python):
def main():
    K = int(input())
    mod = 7

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

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

if __name__ == "__main__":
    main()

Solution (Python):
import sys
import math

def input(): return sys.stdin.readline().rstrip("\r\n")
def List(): return list(map(int, input().split()))
def Num(): return int(input())


n = Num()
seven = 7
for I in range(n):
    if seven % n == 0:
        print(I + 1)
        break
    seven = seven * 10 + 7
    seven %= n
else:
    print(-1)

Solution (Python):
k = int(input())

flag = False

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

if flag:
    print(i+2)
else:
    print(-1)

Solution (Python):
k=int(input())
def exit():
    import sys
    sys.exit()
if k%10 in [0,2,4,5,6,8,]:
    print(-1)
    exit()
i=1
if k%7==0:
    a=10%(9*k/7)
else:
    a=10%(9*k)
while 1:
    if k%7==0:
        if a==1:
            print(i)
            exit()
        a=(a*10)%(9*k/7)
    else:
        if a==1:
            print(i)
            exit()
        a=(a*10)%(9*k)
    i+=1

Solution (Python):
import sys
import numpy as np
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    np.set_printoptions(threshold=20)
    K = int(input())
    if K % 2 == 0 or K % 5 == 0:
        print(-1)
        return
    cnt = 0
    now = 7
    while True:
        cnt += 1
        if now % K == 0:
            print(cnt)
            return
        now = now * 10 + 7
        now %= K


if __name__ == '__main__':
    main()

Solution (Python):
k = int(input())
now = 7

for i in range(1,k+1):
    tmp = now % k
    if tmp == 0:
        print(i)
        exit()
    else:
        now = tmp * 10 + 7
else:
    print(-1)

Solution (Python):
import sys,bisect,string,math,time,functools,random,fractions
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
rep=range;R=range
def Golf():n,*t=map(int,open(0).read().split())
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def MI():return map(int,input().split())
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def Ra():return map(int,open(0).read().split())
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in range(V)]
    FromStdin=True if ls==None else False
    for i in range(E):
        if FromStdin:
            inp=LI()
            org_inp.append(inp)
        else:
            inp=ls[i]
        if len(inp)==2:
            a,b=inp;c=1
        else:
            a,b,c=inp
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'
    
    mp=[boundary]*(w+2);found={}
    for i in R(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def accum(ls):
    rt=[0]
    for i in ls:rt+=[rt[-1]+i]
    return rt
def bit_combination(n,base=2):
    rt=[]
    for tb in R(base**n):s=[tb//(base**bt)%base for bt in R(n)];rt+=[s]
    return rt
def gcd(x,y):
    if y==0:return x
    if x%y==0:return y
    while x%y!=0:x,y=y,x%y
    return y
def YN(x):print(['NO','YES'][x])
def Yn(x):print(['No','Yes'][x])
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

mo=10**9+7
inf=float('inf')
FourNb=[(-1,0),(1,0),(0,1),(0,-1)];EightNb=[(-1,0),(1,0),(0,1),(0,-1),(1,1),(-1,-1),(1,-1),(-1,1)];compas=dict(zip('WENS',FourNb));cursol=dict(zip('LRUD',FourNb))
l_alp=string.ascii_lowercase
sys.setrecursionlimit(10**9)
read=sys.stdin.buffer.read;readline=sys.stdin.buffer.readline;input=lambda:sys.stdin.readline().rstrip()




def dijkstra(edge,st):
    
    
    n=len(edge)
    d=[(0 if st==i else inf) for i in range(n)]
    q=[(j,i) for i,j in enumerate(d)]
    heapify(q)
    v=[False]*n
    
    while q:
        dist,cur=heappop(q)
        if v[cur]:
            continue
        v[cur]=True
        for dst,dist in edge[cur]:
            alt=d[cur]+c[cur]
            if alt<d[dst]:
                d[dst]=alt
                heappush(q,(alt,dst))
    return d

class UnionFind:
    def __init__(self, n):
        
        
        self.table = [-1] * n
 
    def _root(self, x):
        if self.table[x] < 0:
            return x
        else:
            
            self.table[x] = self._root(self.table[x])
            return self.table[x]
 
    def find(self, x, y):
        return self._root(x) == self._root(y)
 
    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            if d1 == d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2
    
    def __str__(self):
        rt=[i if j<0 else j for i,j in enumerate(self.table)]
        return str(rt)

class Comb:
    def __init__(self,n,mo=10**9+7):
        self.fac=[0]*(n+1)
        self.inv=[1]*(n+1)
        self.fac[0]=1
        self.fact(n)
        for i in range(1,n+1):
            self.fac[i]=i*self.fac[i-1]%mo
            self.inv[n]*=i
            self.inv[n]%=mo
        self.inv[n]=pow(self.inv[n],mo-2,mo)
        for i in range(1,n):
            self.inv[n-i]=self.inv[n-i+1]*(n-i+1)%mo
        return
    
    def fact(self,n):
        return self.fac[n]
        
    def invf(self,n):
        return self.inv[n]

    def comb(self,x,y):
        if y<0 or y>x:
            return 0
        return self.fac[x]*self.inv[x-y]*self.inv[y]%mo



show_flg=False
show_flg=True

ans=0


k=I()
x=0
s=7
for i in range(k+1):
    x+=s
    x%=k
    if x==0:
        print(i+1)
        exit()
    s=s*10%k

print(-1)

Solution (Python):
k = int(input())
c = 0
x = 7
found = False
while c <= k:
    if x % k == 0:
        found = True
        break
    c += 1
    x = ((x * 10) + 7) % k

if not found:
    print(-1)
else:
    print(c + 1)

Solution (Python):
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return map(int, sys.stdin.readline().split())
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())


def FLIST(n):
    res = [1]
    for i in range(1, n+1):
        res.append(res[i-1]*i % DVSR)
    return res


K = II()

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

print(res)

Solution (Python):
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    sevens = 0
    for i in range(1, K + 1):
        sevens = sevens * 10 + 7
        sevens %= K
        if sevens == 0:
            print(i)
            exit()
    print(-1)

Solution (Python):
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)

Solution (Python):
K = int(input())
if K%5 == 0 or K%2 == 0:
    print(-1)
    exit()
x = 7
counter = 1
while True:
    if x%K == 0:
        print(counter)
        exit()
    counter += 1
    x = (10 * x + 7) % K

Solution (Python):
K = int(input())

now = 7
r = 0
for d in range(1, K + 100):
    r = (r * 10 % K + 7) % K
    if r == 0:
        print(d)
        break
else:
    print(-1)

Solution (Python):
k = int(input())

ans = 1
mod = 7

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

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

Solution (Python):
K=int(input())
if K%5==0 or K%2==0:
    print(-1)
if K%7==0:
    L=9*K//7
else:
    L=9*K
R=1
for i in range(L):
    R=R*10
    R=R%L
    if R==1:
        print(i+1)
        exit()

Solution (Python):
K = int(input())

cur = 0
for i in range(K + 1):
    cur = (cur * 10 + 7) % K
    if cur == 0:
      print(i + 1)
      exit(0)

print(-1)

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

    x = 7 % K
    s = set()
    i = 1

    while True:
        
        if x == 0:
            print(i)
            return

        
        if x in s:
            print(-1)
            return

        s.add(x)
        x = (x * 10 + 7) % K
        i += 1


if __name__ == "__main__":
    main()

Solution (Python):
K = int(input())

if (K%10) % 2 == 0:
    print(-1)

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

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

Solution (Python):
k = int(input())
sv = 7
for i in range(1, 10**6 + 1):
    if sv % k == 0:
        print(i)
        exit()
    sv = (sv * 10 + 7) % k
print(-1)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
import sys
K = int(input())

if K % 2 == 0:
    print(-1)
    sys.exit()

if K % 5 == 0:
    print(-1)
    sys.exit()

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

i = 1
mod = 10**i % L
while True:
    if mod == 1:
        print(i)
        sys.exit()

    mod = mod * 10 % L
    i += 1

Solution (Python):
K=int(input())

a=7%K
i=1
dp=[0 for n in range(K)]
dp[a]=1

while a!=0:
   a=(10*a+7%K)%K
   if dp[a]==0:
       dp[a]+=1
       i+=1
   else:
       print(-1)
       break
else:
    print(i)