peterverebics/CodeNet_Python_118 huggingface dataset:
def main():
    K = int(input())
    if K % 2 == 0 or K % 5 == 0:
        print(-1)
        return
    cnt = 1
    tmp = 7
    while tmp % K != 0:
        tmp = tmp * 10 + 7
        tmp %= K
        cnt += 1

    print(cnt)

main()
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
#
K = int(input())
if K%2==0 or K%5==0:
  print(-1)
elif K == (1 or 7):
  print(1)
else:
  mod = 7 % K
  mod_plus = mod
  i = 0
  while mod != 0:
    i += 1
    mod_plus = (mod_plus*10) % K
    mod = (mod + mod_plus) % K
  print(i+1)
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()
m = 7 % K
cnt = 1
d = 10 % K
while True:
    if m == 0:
        break
    cnt += 1
    m = (m+7*d)%K
    d = d*10%K
print(cnt)
k = int(input())
n = 0
for i in range(k+1):
    n += pow(10, i, k)*7
    n %= k
    if n==0:
        print(i+1)
        break
else:
    print(-1)
K=int(input())

X=[0]*K
m=0
p=7
for i in range(K):
  m=(m+p)%K
  if m==0:
    print(i+1)
    break
  elif X[m]==1:
    print(-1)
    break
  else:
    X[m]=1
  p=(p*10)%K
import sys
k = int(input())

a = [0]*k
a[0] = 7 % k

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

for i in range(k):
    if a[i] == 0:
        print(i+1)
        sys.exit()
print(-1)
import math
import pprint
import fractions
import collections
import itertools
from decimal import *
from collections import deque
from bisect import *
K=int(input())
flag=0
cnt=0
ans=0
for i in range(K):
    cnt=(cnt+7*pow(10,i,K))%K
    if cnt==0:
        flag=1
        ans=i+1
        break
if flag==0:
    print(-1)
else:
    print(ans)
n=int(input())
if(n%2==0 or n%5==0):
    print(-1)
else:
    a=7 
    ans=1
    flag=1  
    while(flag):
        if(a%n==0):
            print(ans)
            flag=0
            break 
        else:
            ans+=1 
            s=str(a)
            s1='7'
            s2=int(s+s1)
            a=(int(s2))%n
K = int(input())

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

i = 0
sevens = 0
while True:
    sevens += 7 * pow(10, i, K)
    sevens %= K
    i += 1
    if sevens == 0:
        break
print(i)
k = int(input())

x = 7

for i in range(k):
    if x%k==0:
        print(i+1)
        exit()
    x = (x*10 + 7)%k
print("-1")
k = int(input())
n = 0
for i in range(1, k+1):
    n = (n * 10 + 7) % k
    if n == 0:
        print(i)
        exit()
print('-1')
k=int(input())
t=7
for i in range(k):
    if t%k==0:
        print(i+1)
        break
    else:
        t=(10*t+7)%k
else:
    print(-1)
amari=0
k=int(input())
for i in range(k+1):
	amari+=7*pow(10,i,k)
	amari%=k
	if amari==0:
		print(i+1)
		exit()
print(-1)
def main():
    k = int(input())
    n = 7
    if k % 2 == 0:
        print(-1)
    else:
        for i in range(10 ** 7):
            if n % k == 0:
                print(i + 1)
                break
            n = (10 * n + 7) % k
        else:
            print(-1)


if __name__ == '__main__':
    main()
def main():
    K = int(input())
    v = 7 % K
    for i in range(K+5):
        if v == 0:
            print(i+1)
            return
        v = v * 10 + 7
        v %= K
    print(-1)


if __name__ == '__main__':
    main()
k =int(input())

if k % 2 == 0 or k % 5 == 0:
  print(-1)
else:
  if k % 7 == 0:
    k //= 7
  if k == 1:
    print(1)
  else:
    k *= 9
    i = 1
    num = 10
    while num % k != 1:
      num %= k
      num *= 10
      i += 1
    print(i)
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)
k = int(input())
rem = 7%k
alreadys = [False]*k
alreadys[rem] = True

ans = 1
while True:
    if rem == 0:
        print(ans)
        exit()
    ans += 1
    rem = (rem*10+7)%k
    if alreadys[rem]:
        print(-1)
        exit()
    alreadys[rem] = True
K = int(input())

def main(K):
  cnt = 1
  amari = 0
  while True:
    amari *= 10
    amari += 7
    amari %= K
    if amari == 0:
      return cnt
    else:
      cnt += 1
  

if K % 2 == 0 or K % 5 == 0:
  print(-1)
else:
  print(main(K))
K = int(input())
X = 7
p = 0
for i in range(1, K+2):
  p = (p + X)%K
  if(p == 0):
    print(i)
    exit()
  X = (X*10)%K
print(-1)
k=int(input())
cnt=0
for i in range(10**6+1):
    cnt+=7*pow(10,i,k)
    cnt%=k
    if cnt==0:
        print(i+1)
        exit()
print(-1)
K = int(input())

def calculate(k):

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

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

    res = 1

    m = (((10 ** res) - 1) // 9) * 7


    while m % k > 0:
        res += 1
        m = m % k
        m = m * 10 + 7

    print(res)


calculate(K)
import sys

def resolve():
    readline=sys.stdin.readline
    k=int(readline())
    to=10**6
    svn=[0]*to
    svn[0]=7%k
    if svn[0]==0:
      print(1)
      return
    for i in range(1,to):
      svn[i]=(svn[i-1]*10)%k
    for i in range(1,to):
      svn[i]+=svn[i-1]
      if svn[i]%k==0:
        print(i+1)
        return
      
    print(-1)
    return
resolve()
K = int(input())
sevens = 7
if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    i = 1
    while True:
        if sevens % K == 0:
            print(i)
            break
        sevens = (sevens % K)*10+7
        i += 1
K = int(input())
r = 7 % K
ans = -2
for i in range(K):
   if r == 0:
      ans = i
      break
   r = 10*r + 7
   r = r % K
print(ans+1)
import sys
sys.setrecursionlimit(10**6)


def main(input, print):
    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(sys.stdin.readline, print)
K = int(input())
a = 7 % K
cnt = 1
while a:
    a = (10*a+7) % K
    cnt += 1
    if K < cnt:
        cnt = -1
        break
print(cnt)
K = int(input())

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

print(-1)
k=int(input())

d=7%k
c=-1
for i in range(10**6+10):
    if d==0:
        c=i+1
        break
    d=(d*10+7)%k

    
print(c)
# C - Repsept
def get_mod(prev_mod):
	global K
	
	return (prev_mod * 10 + 7) % K


K = int(input())
mod = 0
count = 0
mods = set()

while True:
	mod = get_mod(mod)
	count += 1
	
	if mod == 0:
		print(count)
		break
	else:
		if mod in mods:
			print(-1)
			break
		else:
			mods.add(mod)
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)
K = int(input())

num = 0
cnt = 0
ans = -1

for i in range(K):
    num = num*10 +7
    cnt += 1
    if num%K != 0:
        num = num%K
    else:
        ans = cnt
        break
    
print(ans)
K = int(input())

x = 7%K

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

K = int(input())

seven = 0
for i in range(K+2):
    seven += (7 * pow(10, i, K)) % K
    seven %= K    
    if seven == 0:
        print(i+1)
        sys.exit()

print(-1)
K = int(input())
f = 1
j = 7%K
while f < K and j != 0:
  j = (j*10 + 7)%K
  f += 1
if j == 0:
  print(f)
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())

if k % 2 == 0 or k % 5 == 0:
  print(-1)
else:
  num = 7
  ans = 1
  while num % k != 0:
    num *= 10
    num += 7
    ans += 1
    num %= k
  print(ans)
import sys

k=int(input())
mae=0

for i in range(10**6+1):
  now=(10*mae+7)
  if now%k==0:
    print(i+1)
    sys.exit()
  mae=now%k

print(-1)
# coding: utf-8
# Your code here!

K = int(input())

s = 7 % K
for i in range(1, K+1) : 
    if i != 1 : 
        s = (10*s + 7) % K

    if s == 0 : 
        print(i)
        exit()

print(-1)
k = int( input() )

# a = 7
# for _ in range( 30 ):
#     print( a % k )
#     a = 10 * a + 7

rem_list = []
first_rem = 7 % k
a = 7
cnt = 0
while True:
    r = a % k
    cnt += 1
    if r == 0:
        print( cnt )
        break
    elif cnt > 2 and cnt > k:
        print( -1 )
        break
    else:
        a = ( 10 * r + 7 ) % k
K = int(input())

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

count = 0
an = 0
while True:
  an = (10*an + 7) % K
  count +=1
  if an == 0:
    break
print(count)
k = int(input())
n = 0
for i in range(10**6 + 1):
    n += 7 * pow(10, i, k)
    n %= k
    if n % k == 0:
        print(i+1)
        exit()

print(-1)
k = int(input())
dic = dict()
cnt = 1
num1 = 7 % k
num2 = 70 % k
while True:
    if dic.get(num1):break
    if (num1) == 0:
        print(cnt)
        exit()
    
    dic[num1] = 1
    num1 = (num1 + num2) %k
    num2 = (num2 * 10) %k
    cnt += 1
    #print(num1, num2)
print(-1)
from collections import defaultdict
K = int(input())
if K % 2 == 0:
    print(-1)
    exit()
c = 1
d = 7 % K
D = defaultdict(int)
while True:
    if d == 0:
        print(c)
        exit()
    if D[d] == 1:
        print(-1)
        exit()
    D[d] += 1
    c += 1
    d = (d * 10 + 7)%K
K = int(input())

N = 1000000
x = 7 % K

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

if i == N:
    i = -1

print(i)
k=int(input())
x=7
cnt=1
if k%2==0:
    print(-1)
else:
    while True:
        if x%k ==0:
            print(cnt)
            break
        elif cnt<10000000:
            x=(x*10+7)%k
            cnt+=1
        else:
            print(-1)
            break
k = int(input())
 
s = 7
for i in range(1, k+1):			# rangeの上限がk
    if s % k == 0:
        print(i)
        break
    s = (s * 10 + 7) % k		# %kが難しい
else:                           # for文にもelseが使える
    print(-1)
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)
K=int(input())
t=0
for i in range(K+2):
  t=(10*t+7)%K
  if t%K==0:
    ans=i+1
    break
else:
  ans=-1
print(ans)
import math
k = int(input())

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

print(ans)
import functools

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

mod=0

for i in range(1,pow(10,6)):
    mod=(mod*10+7)%K
    if mod==0:
        print(i)
        exit(0)
        
print(-1)
(K,) = [int(x) for x in input().split()]
ans = 0
seven = 7
for i in range(1000000):
    if seven % K == 0:
        print(i + 1)
        break
    seven = (10 * seven + 7) % K
else:
    print(-1)
k = int(input())

t = 7
t %= k

for i in range(k+1):
    if t == 0:
        print(i+1)
        break
    #常に余りを用いる　⇒　10**7桁の演算
    t = (t*10 + 7)%k
else:print(-1)

"""
else:
for(while)文を
break文で抜ける（真）　⇒　実行しない
forのイテラブルを使い切る、whileが偽になる　⇒　実行する
"""
k=int(input())
if k%2==0 or k%5==0:
    print(-1)
    exit()
a=7
ans=1
while ans<10**7:
    if a%k==0:
        print(ans)
        exit()
    a%=k
    a*=10
    a+=7
    ans+=1
K = int(input())
flag = 0
now = 0
for i in range(1,K+1):
    now = now +  7*pow(10, i-1, K)
    now = now%K
    if now==0:
        flag = 1
        print(i)
        break
if flag==0:
    print(-1)
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    k = int(input())
    ans = 1

    if k % 2 == 0 or k % 5 == 0:
        print(-1)
    else:
        a = 7
        while 1:
            if a % k == 0:
                print(ans)
                break
            else:
                a = (a % k) * 10 + 7
                ans += 1
if __name__ == '__main__':
    main()
K = int(input())
cur = 7
for n in range(K):
    if cur % K != 0:
        cur = (cur * 10 + 7) % K
    else:
        print(n + 1)
        break
else:
    print(-1)
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)
else:
    rest = 1
    ans = 0
    while True:
        rest *= 10
        ans += 1
        rest = rest % L
        if rest == 1:
            break
    print(ans)
K  = int(input())
a = 0

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

print(-1)
#!/usr/bin python3
# -*- coding: utf-8 -*-

k = int(input())
if k%2==0 or k%5==0:
    print(-1)
else:
    ret = 1
    res = 7%k
    while res != 0:
        res = (res * 10 + 7) % k
        ret += 1
    print(ret)
def first_multiple(k):
    n = 0
    for i in range(1, k + 1):
        n = (n * 10 + 7) % k
        if n % k == 0:
            return i
    return -1


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

isCorrect = False
for i in range(K):
  if a[i] == 0:
    print(i+1)
    isCorrect = True
    break
if not isCorrect:
  print("-1")
k=int(input())
count=1
num=7
for _ in range(k):
    if num%k == 0:
        print(count)
        break
    else:
        count += 1
        num = (num % k)*10 + 7
else:
    print(-1)
k=int(input())

a=[]
judge=0
a.append("")
a.append(7%k)
for i in range(2,10**6+1):
    a.append((a[i-1]*10+7)%k)
for i in range(1,k+1):
    if a[i]==0:
        print(i)
        judge=1
        break
if judge==0:
    print(-1)
k = int(input())
if k==1 or k==7:
  print(1)
elif k%2==0:
  print(-1)
else:
  cnt = 1
  pre = 7
  while(True):
    surp = (pre*10+7)%k
    cnt += 1
    if surp==0:
      break
    if cnt>1000000:
      cnt = -1
      break
    pre = surp
  print(cnt)
def solve(K):
    a = 7 % K
    for i in range(1, K+1):
        if a == 0:
            return i
        a = (a * 10 + 7) % K
    return -1 

        

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

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

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

ans = -1
n = 10
for i in range(1, L):
    surplus = n % L
    if surplus == 1:
        ans = i
        break
    n = 10 * surplus
print(ans)
n = int(input())
s = 7
for i in range(1, int(3e6)):
    if s%n == 0:
        print(i)
        exit()
    s = (s*10 + 7) % n
print(-1)
import sys
input = sys.stdin.readline

def main():
    K = int(input())
    
    if K%2==0:
        return -1
    
    if K % 7:
        L = 9*K
    else:
        L = 9*K//7
    a = 1
    for i in range(1,L+1):
        a = (a * 10) % L
        if a == 1:
            return i
    return -1
ans =main()
print(ans)
K = int(input())
F = set()
val = 7
flg = True
for i in range(K+6):
  if val % K == 0:
    flg = False
    print(i+1)
    break
  F.add(val%K)
  val *= 10
  val += 7
  val %= K
  if val % K in F:
    break
if flg:
  print(-1)
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())
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)
K = int(input())
j = 7%K
p = -1
for i in range(1,K+1):
    if j == 0:
        print(i)
        p = 0
        break
    j = ((j*10)+7)%K
if p == -1:
    print("-1")
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()
K = int(input())
m = 0
for k in range(1,K + 1):
  m = m * 10 + 7
  m = m % K
  if m == 0:
    print(k)
    break
if m > 0:
  print(-1)
k = int(input())
val = 7
val %= k
for i in range(k+1):
	if(val ==0):
		print(i+1)
		break
	val = (val * 10 + 7) % k
else:
	print(-1)
k = int(input())
m = 7
if(k%2==0):
  print("-1")
else:
  i = 1
  while True:
    m = m%k
    if(m==0):
      print(i)
      break  
    if(i>k):
      print("-1")
      break
    m *= 10
    m += 7
    i += 1
def main():
    K = int(input())
    a = 7 % K
    for i in range(1, K+1):
        if a == 0:
            print(i)
            return
        a = a * 10 + 7
        a %= K
    print(-1)


if __name__ == '__main__':
    main()
K = int(input())

a = 7
p = {}
ans = 0

while True:
    t = a % K
    ans += 1
    if t == 0:
        print(ans)
        break
    if t in p:
        print(-1)
        break
    a = 10*t + 7
    p[t] = 1
k = int(input())
if k%2 == 0:
    ans = -1
else:
    x = 0
    ans = -1
    for i in range(10**6+1):
        x += 7*pow(10, i, k)
        x %= k
        if x%k == 0:
            ans = i+1
            break
print(ans)
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 14 13:35:45 2020

@author: ezwry
"""

k = int(input())
a = 7

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

print(-1)
k = int(input())
if k % 2 == 0 & k % 5 == 0:
    print(-1)
    exit()

x = 7 % k
s = set()
i = 1
ans = -1
while x not in s:
    if x == 0:
        ans = i
        break
    s.add(x)
    x = (10 * x + 7) % k
    i += 1
    
print(ans)
k = int(input())
s = 7
num = 1
res = True
if k == 2:
    print(-1)
else:
    for i in range(k):
        s %= k
        if s == 0:
            res = False
            print(num)
            break
        num += 1
        s *= 10
        s += 7
    if res:
        print(-1)
k=int(input())
a=0
for i in range(k):
  a+=7*pow(10,i,k)
  a%=k
  if a==0:
    print(i+1)
    exit()
print(-1)
n = int(input())
if n==0:
    print(0)
if n%2==0:
    print(-1)
elif n%5==0:
    print(-1)
else:
    k=7
    l=1
    k%=n
    while k!=0:
        l+=1
        k*=10
        k+=7
        k%=n
        #print(k)
    print(l)
k = int(input())
n = 0

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

print(-1)
K = int(input())
L,r = K*9 if K%7 else K*9//7, 10
for i in range(1,L+1):
	r %= L
	if r == 1:
		print(i)
		exit()
	r *= 10
print(-1)
k = int(input())
if k%2 == 0 or k%5 == 0:
    print(-1)
else:
    a = 0
    cnt = 1
    while True:
        a = (10*a+7)%k
        if a == 0:
            print(cnt)
            break
        cnt+=1
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)
K = int(input())
if K % 2 == 0 or K % 5 == 0:
  print(-1)
  exit()
i, ai = 0, 0
while True:
  ai = (ai * 10 + 7) % K
  i += 1
  if ai == 0:
    print(i)
    exit()
K = int(input())

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

A = 7
ans = 1
while(A < K): #O(6)
    A = A*10 + 7
    ans += 1

while(True):
    #print(A)
    A = A % K #1
    if(ans > K):
        print("-1")
        exit()
    if(A==0): #1
        print(ans)
        exit()
    A = A * 10 + 7 # 1
    ans += 1# 1
import sys
k = int(input())

if k%2 == 0 or k%5 ==0:
    print(-1)
else:
    a = 7%k
    if a == 0:
        print(1)
    else:
        for i in range(2, 10000000):
            a = (10*a+7)%k
            if a == 0:
                print(i)
                sys.exit()
        print(-1)
import sys
k = int(input())
if k % 7 == 0:
    k = k // 7
tmp = 1
for i in range(k+2):
    if tmp % k == 0:
        print(i+1)
        sys.exit()
    tmp = (tmp * 10 + 1) % k
print(-1)
K = int(input())
count = 1
mod = 7
answer = -1

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

print(answer)
K = int(input())
if K == 7 or K == 1:
    print(1)
else:
    if K % 7 == 0:
        K //= 7
    r = 1
    for i in range(1,K+1):
        if r == 0:
            print(i)
            break
        r += pow(10,i,K)
        #print(r)
        r %= K
    else:
        print(-1)
K = int(input())
X = 7
for i in range(1, 10 ** 6 + 1):
    if not X % K:
        print(i)
        exit()
    X = (X + 7 * pow(10, i, K)) % K
print(-1)
import sys
def main():
    k = int(input())

    a =7%k
    if a == 0:
        print(1)
        sys.exit()

    for i in range(2,10**7):
        a = (10*a+7) % k
        if a == 0:
            print(i)
            sys.exit()

    print(-1)
    
main()
def main():
    k = int(input())
    if k & 0:
        print(-1)
        return

    r = 7 % k
    l = 0
    while r and l < k:
        r = (r * 10 + 7) % k
        l += 1

    print([l+1, -1][l == k])


if __name__ == '__main__':
    main()
K = int(input())
ans = 7%K
A = 1
C = [0]*K
if K == 1 or K == 7:
  print(1)
  exit()
for i in range(K):
  A = (A*10)%K
  ans += (A*7)
  ans %= K
  if ans == 0:
    break
  if C[ans] == 0:
    C[ans] += 1
  else:
    print(-1)
    exit()
print(i+2)
import sys
K=int(input())
L=9*K
if L%7==0:
  L = L//7
n = 1
for i in range(1,K+1):
  n = n * 10 % L
  if n == 1:
    print(i)
    sys.exit()
print(-1)
k = int(input())
a = 7 % k
count = 1
for i in range(1,k+1):
  if a == 0:
    print(count)
    break
  else:
    a = (10 * a + 7) % k
    count += 1
    if i == k:
      print(-1)
K = int(input())
ans = -1
t = 0
for i in range(10**6):
  t = t * 10 + 7
  t %= K
  if t == 0:
    ans = i + 1
    break
print(ans)
k = int(input())
ans = 1
mod = 7

for i in range(k):
    if mod % k != 0:
        ans += 1
        mod = (mod * 10 + 7) % k
    else:
        break
        
print(ans if mod%k == 0 else "-1")
#ABC 174 C
k = int(input())

sevens = [0] * k

sevens[0] = 7 % k

if k == 7 or k == 1:
    print(1)
    
else:
    for i in range(1, k):
        new = (sevens[i - 1] * 10 + 7) % k
        sevens[i] = new

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

x=7%K
i=1
flag=0
for j in range(K+1):
  if x==0:
    print(i)
    flag=1
    break
  x=(10*x+7)%K
  i+=1


if flag==0:
  print(-1)
K = int(input())
 
x = []
x.append(7%K)
for i in range(1,K):
  x.append((x[i-1]*10+7)%K)

for i,n in enumerate(x):
  if n == 0:
    print(i + 1)
    exit()
print(-1)
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)
K = int(input())

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

res = -1
count = 0
ai = 0
while(True):
    ai = (ai*10 + 7) % K
    count += 1
    if(ai == 0):
        res = count
        break

print(res)
K = int(input())
Ali = []

s = 7
if s%K == 0:
  print(1)
  exit()
for i in range(1000100):
  s = (s*10+7)%K
  if s%K == 0:
    print(i+2)
    exit()
  
print(-1)
k = int(input())
curr = 7
for i in range(k):
  if curr%k:
    curr *= 10
    curr += 7
    curr %= k
  else:
    print(i+1)
    break
else:
  print(-1)
res = 7
cnt = 1
k = int(input().rstrip())
res_list = [0 for _ in range(k)]
flg = 0
while True:
  res %= k
  if res == 0:
    flg = 1
    break
  if res_list[res] == 1:
    break
  res_list[res] = 1
  cnt += 1
  res = res * 10 + 7
if flg == 1:
  print(cnt)
else:
  print(-1)
K = int(input())

t = 7
ans = 1

for _ in range(K):
    if t % K == 0:
        print(ans)
        exit(0)
    else:
        t = (t * 10 + 7) % K
        ans += 1

print(-1)
def main(k):
    r0 = 7 % k
    if r0 == 0:
        print(1)
        return
    if k % 2 == 0 or k % 5 == 0:
        print(-1)
        return
    rs = [r0]
    while True:
        ri = (10 * rs[-1] + r0) % k
        if ri == 0:
            break
        rs.append(ri)
        if len(rs) >= 3 and rs[-1] == rs[-2] == rs[-3]:
            print(-1)
            return
    print(len(rs) + 1)


main(int(input()))
def main():
    n = int(input())
    mod = 0
    pow10 = 1
    for i in range(20*n):
        mod = (mod+7*pow10) % n
        if mod == 0:
            print(i+1)
            return
        pow10 = pow10*10 % n
    print(-1)


main()