Harryxun/stf_run huggingface dataset:
K = int(input())

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

### FIXED CODE ###

K = int(input())

for i in range(K):
    if i == 0:
        N= 7%K
    else:
        N = (10*N+7)%K
    if N == 0:
        print(i+1)
        break
else:
    print(-1)
n=int(input())
wordlist=[input() for i in range(n)]
sortlist=[]
for i in range(n):
    a=list(wordlist[i])
    a.sort()
    a="".join(a)
    sortlist.append(a)
    
def kaijyo(n):
    ans=1
    for i in range(2,n+1):
        ans*=i
    return ans

count=0
sortlist.sort()


while sortlist:
    a=sortlist.pop()
    times=sortlist.count(a)+1
    for i in range(times-1):
        sortlist.pop()
    count+=kaijyo(times)*kaijyo(times-2)/2
    
print(count/2)   

### FIXED CODE ###

n=int(input())

#単語が全て入ったリストを作るO(n)
wordlist=[input() for i in range(n)]

#wordlistを一つ一つソートさせたものをsortlistとして作るO（n）
sortlist=[]
for i in range(n):
    a=list(wordlist[i])
    a.sort()
    sortlist.append(a)
    
count=0

#ソートリストをソートするO(nlogn)
sortlist.sort()

checkword=""
check=0

for i in range(n): #O(n)
    a=sortlist.pop()
    if checkword==a:
            check+=1
            count+=check
    else:
        check=0
        checkword=a
    
print(int(count) )
N = int(input().split())
a = list(map(int, input().split()))

s = [a.index(i)+1 for i in range(1, N+1)]

result = " ".join(map(str, s))
print(result)

### FIXED CODE ###


N = int(input())
a = list(map(int, input().split()))
s = [-1]
s.extend(0 for _ in range(N))

for i, item in enumerate(a):
    s[item] = i+1

result = " ".join(map(str, s[1:]))
print(result)
K, N = map(int,input().split())
a = list(map(int,input().split()))
x = [a[0]-a[-1]+K]
for i in range(1,N):
    x.append(a[i]-a[i-1])
print(x)
print(K-max(x))

### FIXED CODE ###

import math
N, K = map(int, input().split())
N = N%K
while True:
    if abs(N-K) < N:
        N = abs(N-K)
    else:
        print(N)
        break
import numpy as np
import math
x = int(input())
flag = False
for i in range(10**10):
    for j in range(1,10**10):
        if (i+j)**5-i**5 == x:
            print(i+j,j)
            flag = True
            break
        elif (i+j)**5-i**5 > x:
            break
    if Flag:
        break

### FIXED CODE ###

import numpy as np
import math
x = int(input())
ys = []
i = 1
while i**2 < x:
    if x%i == 0:
        ys.append(i)
        ys.append(x//i)
    i += 1
if i**2 == x:
    ys.append(i)

f = False

for j in ys:
    for i in range(10**3):
        if i**5-(i-j)**5 == x:
            print(i,i-j)
            break
        elif i**5-(i-j)**5 > x and i-j > 0:
            break
    if f:
        break
N = int(imput())
a = round(N/2)/N
print(a)

### FIXED CODE ###

import math
N = int(input())
a = math.ceil(N/2)/N
print(a)
import numpy as np

N = int(input())
Ps = list(map(int, input().split()))
Ps = np.array(Ps)
count = 0

for i in range(N):
    low = Ps[i]
    if ( np.sum(Ps[:i] < low) == 0):
        count += 1

print(count)

### FIXED CODE ###

N = int(input())
Ps = list(map(int, input().split()))
count = 0
min = Ps[0]+1

for i in range(N):
    if (Ps[i] < min):
        min = Ps[i]
        count += 1

print(count)
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

n,k=map(int,input().split())
a=list(map(int,input().split()))
m=0
if k==0:
    m=int(math.log2(1)+1)
else:
    m=int(math.log2(k)+1)
lst=[0]*m
for i in range(n):
    for j in range(m):
        if a[i]&(1<<j):
            lst[j]+=1
# print(lst)

ans=0
ans2=0
for i in range(m):
    if lst[i]<=n/2 and ans+pow(2,i)<=k:
        ans+=pow(2,i)
# print(ans)
# print(ans2)
for i in range(n):
    ans2+=ans^a[i]

print(ans2)

### FIXED CODE ###

import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

n,k=map(int,input().split())
a=list(map(int,input().split()))
m=0
if k==0:
    m=int(math.log2(1)+1)
else:
    m=int(math.log2(k)+1)
lst=[0]*m
for i in range(n):
    for j in range(m):
        if a[i]&(1<<j):
            lst[j]+=1
# print(lst)

ans=0
ans2=0
for i in range(m):
    if lst[m-i-1]<=n/2 and ans+pow(2,m-i-1)<=k:
        ans+=pow(2,m-i-1)
# print(ans)
# print(ans2)
for i in range(n):
    ans2+=ans^a[i]

print(ans2)
def resolve():
    nclo=range(int(input()))
    from math import gcd
    def lcm(a,b):
        return (a*b)//gcd(a,b)
    next=0
    temp=1
    for i in nclo:
        next=int(input())
        temp=lcm(temp,next)
    print(temp)
        
#%%submit!
resolve()

### FIXED CODE ###

# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(x):
    print(x,file=sys.stderr)
def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())

#繰り返し自乗法だよ
#これはnのp乗をmで割ったあまりをだすよ
def modular_w_binary_method (n,m,p):
    ans=1 if n>0 else 0
    while(p>0):
        if p%2==1:
            ans=(ans*n)%m
        n=(n**2)%m
        p//=2
    return ans
#mod上でのaの逆元を出すよ
"""
    フェルマーの小定理より a**(p)%p==a isTrue
    これを利用すれば a**(p-2)%p==a**(-1) isTrue
    元と逆元とをかけてpで割れば1が余るよ！
"""
def modular_inverse(a,prime):
    return(modular_w_binary_method(a,prime,prime-2))
#逆元を使うと容易に頑張れるｃ
def conbination(n,a,mod=10**9+7):
    #cはイラない
    res=1 
    for s in range(a):
        res=(res*(n-s)*(modular_inverse(s+1,mod)))%mod

        
    return res
#操作から作れるものの組み合わせは何個かー＞同じものでも違う方法で構成できるかから考える方法もある
"""
"""

#solution:

#input
N,=pin()
T=[int(input()) for i in range(N)]
from fractions import gcd
def lcm2(x, y):
    return (x * y) // gcd(x, y)
def lcm(numbers):
        return reduce(lcm2,numbers,1)
print(lcm(T))

#print(h)
#print(m)
#print(["No","Yes"][cond])
#print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""
import math
a1 = list(map(int, input().split())) 
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a = [a1,a2,a3]

N = int(input())

b = []
for i in range(N) :
    b.append(int(input()))

m = [[0,0,0],[0,0,0],[0,0,0]]

for i in range(N) :
    for j in range(3) :
        for k in range(3) :
            if b[i] == a[j][k] :
                m[j][k] = 1
                
if  m[0].count(1) == 3 or \
    m[1].count(1) == 3 or \
    m[2].count(1) == 3 or \
    [x[0] for x in m].count(1) == 3 or \
    [x[1] for x in m].count(1) == 3 or \
    [x[2] for x in m].count(1) == 3 or \
    (m[0][0] == 1 and m [1][1] == 1 and m [2][2] == 1) or \
    (m[2][0] == 1 and m [1][1] == 1 and m [2][0] == 1) :
    print('Yes')
else :
    print('No')

### FIXED CODE ###

import math
n = int(input())
print (math.ceil(n/2))
h, w = map(int, input().split())
mat = []
for i in range(h):
  mat.append(list(map(int, input().split())))
sousa = []
for y in range(h):
  if y % 2 == 0:
    for x in range(w-1):
      if mat[y][x] % 2 == 1:
        mat[y][x] -= 1
        mat[y][x+1] += 1
        sousa.append((y+1, x+1, y+1, x+1+1))
    x += 1
    if mat[y][x] % 2 == 1 and y < h-1:
        mat[y][x] -= 1
        mat[y+1][x] += 1
        sousa.append((y+1, x+1, y+1+1, x+1))
  if y % 2 == 1:
    for x in range(w-1, 0, -1):
      if mat[y][x] % 2 == 1:
        mat[y][x] -= 1
        mat[y][x-1] += 1
        sousa.append((y+1, x+1, y+1, x+1-1))
    x -= 1
    if mat[y][x] % 2 == 1 and y < h-1:
        mat[y][x] -= 1
        mat[y+1][x] += 1
        sousa.append((y+1, x+1, y+1+1, x+1))

print(len(sousa))
for y,x,y1,x1 in sousa:
  print(y,x,y1,x1)


### FIXED CODE ###

h, w = map(int, input().split())
mat = []
for i in range(h):
  mat.append(list(map(int, input().split())))
sousa = []
for y in range(h):
  if y % 2 == 0:
    x = -1
    for x in range(w-1):
      if mat[y][x] % 2 == 1:
        mat[y][x] -= 1
        mat[y][x+1] += 1
        sousa.append((y+1, x+1, y+1, x+1+1))
    x += 1
    if mat[y][x] % 2 == 1 and y < h-1:
        mat[y][x] -= 1
        mat[y+1][x] += 1
        sousa.append((y+1, x+1, y+1+1, x+1))
  if y % 2 == 1:
    x = w
    for x in range(w-1, 0, -1):
      if mat[y][x] % 2 == 1:
        mat[y][x] -= 1
        mat[y][x-1] += 1
        sousa.append((y+1, x+1, y+1, x+1-1))
    x -= 1
    if mat[y][x] % 2 == 1 and y < h-1:
        mat[y][x] -= 1
        mat[y+1][x] += 1
        sousa.append((y+1, x+1, y+1+1, x+1))

print(len(sousa))
for y,x,y1,x1 in sousa:
  print(y,x,y1,x1)
n = int(input())
s = input()
l = [0]*n
for i in range(n):
    l[i] = s[0:i].count('W') + s[i+1:]count('E')
print(min(l))    

### FIXED CODE ###

n = int(input())
s = input()
es = s.count('E')
e_cnt = 0
l = [0]*n
for i in range(n):
    left = i-e_cnt
    if s[i] == 'E':
        e_cnt +=1
    right = es - e_cnt
    l[i] = right+left

print(min(l))
x,a,b = map(str,input().split())
if a>b:
    print('delicious')
elif x>=b-a:
    print('safe')
else:
    print('dangerous')


### FIXED CODE ###

x,a,b = map(int,input().split())
if a>=b:
    print('delicious')
elif x>=b-a:
    print('safe')
else:
    print('dangerous')
r = int(input())
D = int(input())
x = int(input())

for i in range(10):
    x = r * x - D
    print(x)

### FIXED CODE ###

s = input().split()
r = int(s[0])
D = int(s[1])
x = int(s[2])

for i in range(10):
    x = r * x - D
    print(int(x))
i = 1
x = int(input())
for y in x:
    if x == 0:
        break
    print(f 'Case {i}: {y}')
    i += 1



### FIXED CODE ###

case_num = 1

while True:
    tmp_num = int(input())
    if tmp_num == 0:
        break
    else:
        print("Case %d: %d" % (case_num,tmp_num))
        case_num += 1
K = int(input())

def S(x) :
    ret = 0
    while x :
        ret += x % 10
        x //= 10
    return ret

v = [1]
n = [1]
for i in range(2, 1000) :
    x = i / S(i)
    while v[-1] > x :
        v.pop()
        n.pop()
    v.append(x)
    n.append(i)

suf = 99
for i in range(2, 11) :
    for j in range(10, 100) :
        k =  j * (10 ** i) + suf
        x = k / S(k)
        while v[-1] > x :
            v.pop()
            n.pop()
        v.append(x)
        n.append(k)
    
    suf = suf * 10 + 9

for i in range(K) :
    print(n[i])

### FIXED CODE ###

K = int(input())

def S(x) :
    ret = 0
    while x :
        ret += x % 10
        x //= 10
    return ret

L = set()
nine = ''
for i in range(16) :
    for j in range(1, 1000) :
        x = int(str(j) + nine)
        L.add(x)
    nine += '9'
    
L = list(L)
L.sort()

v = [1]
n = [1]

for l in L[1:] :
    x = l / S(l)
    while v[-1] > x :
        v.pop()
        n.pop()
    v.append(x)
    n.append(l)

for i in range(K) :
    print(n[i])
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline

d=int(input().rstrip())
c=[int(i)for i in input().split()]
s=[[int(i)for i in input().split()]for _ in range(d)]
last=[1]*26
for i in range(1,d+1):
    now=[s[i-1][j]-(c[j]*(i-last[j]))for j in range(26)]
    kouho=now.index(max(now))+1
    print(kouho)
    last[kouho]=i

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline

d=int(input().rstrip())
c=[int(i) for i in input().split()]
for _ in range(d):
    s=[int(i) for i in input().split()]
    print(s.index(max(s))+1)
n=int(input())
a,b=map(int,input().split())
if n=="1":
  print("Hello World")
else:
  print(a+b)


### FIXED CODE ###

n=int(input())
if n==1:
  print("Hello World")
else:
  a=int(input())
  b=int(input())
  print(a+b)
import math
n = int(input())
a = list(map(int,input().rstrip().split(' ')))
def lcm(a,b):
  return int(a*b//math.gcd(a,b))
L=1
for x in a:
  L=lcm(L,x)
L-=1
ans=0
for x in a:
  ans+=L%a
print(ans)

### FIXED CODE ###

import fractions
n = int(input())
A = list(map(int,input().rstrip().split(' ')))
def lcm(a,b):
  return int(a*b//fractions.gcd(a,b))
L=1
for x in A:
  L=lcm(L,x)
L-=1
ans=0
for x in A:
  ans+=L%x
print(ans)
(lambda __g, __y, __print: [[(__print(solve(solve(N, A, B), B, A)), None)[1] for (__g['N'], __g['A'], __g['B']) in [((int(input()), list(map(int, input().split())), list(map(int, input().split()))))]][0] for __g['solve'], solve.__name__ in [(lambda n, a, b: (lambda __l: [[(lambda __items, __after, __sentinel: __y(lambda __this: lambda: (lambda __i: [[__this() for __l['dp'][__l['w']] in [(max(__l['w'], ((__l['dp'][(__l['w'] - __l['a'][0])] + __l['b'][0]) if ((__l['w'] - __l['a'][0]) >= 0) else __l['w']), ((__l['dp'][(__l['w'] - __l['a'][1])] + __l['b'][1]) if ((__l['w'] - __l['a'][1]) >= 0) else __l['w']), ((__l['dp'][(__l['w'] - __l['a'][2])] + __l['b'][2]) if ((__l['w'] - __l['a'][2]) >= 0) else __l['w'])))]][0] for __l['w'] in [(__i)]][0] if __i is not __sentinel else __after())(next(__items, __sentinel)))())(iter(range((__l['n'] + 1))), lambda: __l['dp'][-1], []) for __l['dp'] in [(([0] * (__l['n'] + 1)))]][0] for __l['n'], __l['a'], __l['b'] in [(n, a, b)]][0])({}), 'solve')]][0])(globals(), (lambda f: (lambda x: x(x))(lambda y: f(lambda: y(y)()))), __import__('builtins', level=0).__dict__['print'])

### FIXED CODE ###

def solve(n,a,b):
    dp=[0]*(n+1)
    for w in range(n+1): dp[w]=max(w,dp[w-a[0]]+b[0]if w-a[0]>=0 else w,dp[w-a[1]]+b[1]if w-a[1]>=0 else w,dp[w-a[2]]+b[2]if w-a[2]>=0 else w)
    return dp[-1]
N,A,B=int(input()),list(map(int, input().split())),list(map(int, input().split()))
print(solve(solve(N,A,B),B,A))
x = int(input())
num = 11000
arr = list(range(2,num))
arr = set(arr)
primes = {2}

prime = min(arr)
while prime < num-500:
    primes.add(prime)
    nonprime = {prime * i for i in range(1,num//prime + 2)}
    arr = arr.difference(nonprime)
    prime = min(arr)

arr = {i for i in primes if i > x }
print(min(arr))

### FIXED CODE ###

x = int(input())
num = 100200
arr = list(range(2,num))
arr = set(arr)
primes = {2}
floor = int(num**0.5)+2

prime = min(arr)
while prime < floor:
    prime = min(arr)
    primes.add(prime)
    nonprime = {prime * i for i in range(1,num//prime + 2)}
    arr = arr.difference(nonprime)

primes = primes.union(arr)

sol = {i for i in primes if i >= x}

print(min(sol))
N, X = map(int, input().split())

a, p = [1], [1]

for i in range(N):
	a.append(a[i] * 2 + 3)
	p.append(p[i] * 2 + 1)

def f(N, X):
	if N == 0:
		return 0 if X <= 0 else 1
	elif X <= 1 + a[N+1]:
		return f(N-1, X-1)
	else:
		return p[N-1] + 1 + f(N-1, X-2-a[N-1])

print(f(N, X))

### FIXED CODE ###

N, X = map(int, input().split())

a, p = [1], [1]

for i in range(N):
	a.append(a[i] * 2 + 3)
	p.append(p[i] * 2 + 1)

def f(N, X):
	if N == 0:
		return 0 if X <= 0 else 1
	elif X <= 1 + a[N-1]:
		return f(N-1, X-1)
	else:
		return p[N-1] + 1 + f(N-1, X-2-a[N-1])

print(f(N, X))
a = int(input())
b = int(input())
h = int(input())

print(int((a+b)*h //2)

### FIXED CODE ###

a = int(input())
b = int(input())
h = int(input())
 
print(int((a+b)*h//2))
X = input()
    stack = []
    for s in X:
        if not stack:
            stack.append(s)
            continue
        if s == 'T' and stack[-1] == 'S':
            stack.pop()
        else:
            stack.append(s)
    print(len(stack))

### FIXED CODE ###

def resolve():
    X = input()
    stack = []
    for s in X:
        if not stack:
            stack.append(s)
            continue
        if s == 'T' and stack[-1] == 'S':
            stack.pop()
        else:
            stack.append(s)
    print(len(stack))

resolve()
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

Astr = input()
Bstr = input()

if len(Astr) > len(Bstr):
    print("GREATER")
elif len(Astr) < len(Bstr):
    print("LESS")
else:
    for i in range(len(Astr)):
        if int(Astr[i]) > int(Bstr[i]):
            print("GREATER")
            exit()
        elif int(Astr[i]) < int(Bstr[i]):
            print("LESS")
            exit()
    print("EQUAL")


### FIXED CODE ###

# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

# import sys
# input = sys.stdin.readline

A = int(input())
B = int(input())

if A > B:
    print("GREATER")
elif B > A:
    print("LESS")
else:
    print("EQUAL")
import math
a,b,h,m = map(int,input().split())
a_S = (30*h)%360+0.5*m
b_s = (6*m)

s = max(a_s,b_s)-min(a_s,b_s)
ans = math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(s)))
print(ans)

### FIXED CODE ###

import math
a,b,h,m = map(int,input().split())
a_s = (30*h)%360+0.5*m
b_s = (6*m)

s = max(a_s,b_s)-min(a_s,b_s)
ans = math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(s)))
print(ans)
import sys

input = sys.stdin.buffer.readline

n, k = map(int, input().split())

max_n = 300000 + 10
SEG = [0] * (2 * max_n)

func = max
ele = 0


def update(idx, val):
    idx += max_n
    SEG[idx] = val
    for i in reversed(range(1, max_n)):
        SEG[i] = func(SEG[2 * i], SEG[2 * i + 1])


def query(left, right):
    res_left = ele
    res_right = ele
    left += max_n
    right += max_n
    while left < right:
        if left & 1:
            res_left = func(res_left, SEG[left])
            left += 1
        if right & 1:
            right -= 1
            res_right = func(SEG[right], res_right)
        left //= 2
        right //= 2
    return func(res_left, res_right)


for _ in range(n):
    val = int(input())
    # print("range", max(0, val - k), min(max_n + 1, val + k + 1) - 1)
    lower = val - k
    upper = val + k
    if lower < 0:
        lower = 0
    if upper > max_n:
        upper = max_n
    temp = query(lower, upper + 1)
    update(val, temp + 1)


print(SEG[1])



### FIXED CODE ###

import sys

input = sys.stdin.buffer.readline


class SegmentTree:
    ele = 0
    func = max
    # SEG木は1-index
    # Aに関しては0-index

    def __init__(self, n):  # Aは0-idx
        self.n = n
        self.num = 2 ** ((self.n - 1).bit_length())
        self.SEG = [self.ele] * (2 * self.num)

    def search(self, idx):
        return self.SEG[idx + self.num]

    def initialize(self, A):
        for i in range(self.n):
            self.SEG[i + self.num] = A[i]
        for i in range(self.num - 1, 0, -1):
            self.SEG[i] = self.func(self.SEG[2 * i], self.SEG[2 * i + 1])

    # 1点更新
    def set(self, idx, val):
        idx += self.num
        self.SEG[idx] = val
        idx //= 2
        while idx:
            self.SEG[idx] = self.func(self.SEG[2 * idx], self.SEG[2 * idx + 1])
            idx //= 2

    # 区間取得
    def query(self, left, right):
        # 開区間
        resleft = self.ele
        resright = self.ele
        left += self.num
        right += self.num
        while right - left > 0:
            if left % 2 == 1:
                resleft = self.func(resleft, self.SEG[left])
                left += 1
            if right % 2 == 1:
                right -= 1
                resright = self.func(resright, self.SEG[right])
            left //= 2
            right //= 2
        return self.func(resleft, resright)


n, k = map(int, input().split())
ans = 0
ST = SegmentTree(3000001)
for _ in range(n):
    val = int(input())
    lower = val - k
    lower = max(lower, 0)
    upper = val + k
    upper = min(upper, 3000000)
    temp = ST.query(lower, upper + 1) + 1
    ST.set(val, temp)
    ans = max(ans, temp)
print(ans)
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(k):
    b = [0] * n
    for j in range(n):
        b[max(0, j - a[j]):min(n, j + a[j] + 1)] = map(lambda x: x + 1, b[max(0, j - a[j]):min(n, j + a[j] + 1)])
    a = b
print(' '.join([str(_) for _ in a]))


### FIXED CODE ###

s=input()
print(s[:3])
k = int(input())
c = 0
a = [0]*(k+1)
a[0] = 7%k

if k%2 == 0 or k%5 == 0:
	print('-1')
else:
	for i in range(1,k+1):
		c += 1 
		a[i+1] = (10*a[i] + 7)%k
		if a[i+1] == 0:
			break
	print(c)

### FIXED CODE ###

k = int(input())
c = 0
t = 7%k
a = [t]*(k+1)

if k%2 == 0 or k%5 == 0:
	print('-1')
elif 7%k == 0:
	print('1')
else:
	for i in range(1,k):
		c += 1
		a[i+1] = (10*a[i] + 7)%k
		if a[i+1] == 0:
			break
	print(c + 1)
from math import gcd
n = int(input())
arr = [int(x) for x in input().split()]


ans = arr[0]

for i in range(1,n):
    ans = gcd(ans,arr[i])

print(ans)


### FIXED CODE ###

# from math import gcd
def gcd(a,b):
    if b == 0 :return a
    return gcd(b,a%b)


n = int(input())
arr = [int(x) for x in input().split()]


ans = arr[0]

for i in range(1,n):
    ans = gcd(ans,arr[i])

print(ans)
d = input()

if d == "A":
    print("T")
    
else if d == "T":
    print("A")

    
else if d == "C":
    print("G")
    
else:
    print("C")


### FIXED CODE ###

b = input()
ans = ""
for i in range(len(b)):
    if b[i] == "A":
        ans += "T"
    elif b[i] == "T":
        ans += "A"
    elif b[i] == "C":
        ans += "G"
    else:
        ans += "C"
print(ans)
from functools import reduce
import collections

N = int(input())
D = list(map(int, input().split()))

ans = 0
for i in range(N):
    ans += reduce(mul, D)
    queue.popleft()
print(ans)

### FIXED CODE ###

import itertools

N = int(input())
D = list(map(int, input().split()))
S = list(itertools.accumulate(D))

ans = 0
for i in range(N-1):
    ans += D[i]*(S[-1]-S[i])
print(ans)