Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

H, W = map(int, input().split())
map = [list('#' + input() + '#') for j in range(H)]
map.insert(0,['#' for i in range(W + 2)])
map.append(['#' for i in range(W + 2)])


def f(i,j):
    ret = 0
    for x, y in [[0, 1], [1, 0], [0, -1], [-1, 0]]:
        k = 0
        while map[i + x * k][j + y * k] == '.':
            k += 1
        ret += k
    ret -= 3
    return ret

ans = 0
for i, line in enumerate(map):
    for j, dot in enumerate(line):
        if dot == '.':
            ans = max(ans, f(i,j))
print(ans)

### FIXED CODE ###

def main ():
    H, W = map(int, input().split())
    MAP = [list('#' for i in range(W + 2)) for j in range(H + 2)]
    for i in range(H):
        line = list(input())
        for j, dot in enumerate(line):
            MAP[i + 1][j + 1] = dot
    L = [[0 for j in range(W + 2)] for i in range(H + 2)]


    def line(MAP):
        for i in range(1, H + 2):
            before = 0
            for j in range(1, W + 2):
                if MAP[i][j] == '#':
                    for x in range(before + 1, j):
                        L[i][x] = j - before - 1
                    before = j


    def column(MAP2):
        ans = 0
        for j in range(1, W + 2):
            before = 0
            for i in range(1, H + 2):
                if MAP2[i][j] == '#':
                    for y in range(before + 1, i):
                        ans = max(ans, i - before - 1 + L[y][j])
                    before = i
        return ans - 1

    line(MAP)
    column(MAP)
    print(column(MAP))

if __name__ == '__main__':
    main()
### BUGGY CODE ###

n = int(input())
lt = [int(x) for x in input().split()]
 
ans = 1 
for x in lt:
    ans*=x 
if ans > 10**18:
    ans=-1
print(ans)

### FIXED CODE ###

n = int(input())
lt = [int(x) for x in input().split()]
ans =0
if 0 in lt:
    ans=0
else:
    ans = 1 
    for x in lt:
        ans*=x 
        if ans > 10**18:
            ans="-1"
            break 
print(ans)
### BUGGY CODE ###

K,S=map(int,input().split())

#これは立方体の中のどこか一点を選ぶ問題とみなせる
#その中で選ばれた座標の各要素の和が、Sに等しければ良い
#点の総和は(K+1)*3個あり（※ゼロを含むから）、それらが選択可能なx,y,zの集合である
#x,y,zの和がSに達しない場合は、Sを満たす集合はその立方体の外側にある

L=[]
counter=0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            L.append([x,y,z])
            if (S==x+y+z):counter+=1

print(counter)

### FIXED CODE ###

K,S=map(int,input().split())
counter=0
for x in range(K+1):
    for y in range(K+1):
        if (S-x-y<=K) and (S-x-y>=0):counter+=1

print(counter)
### BUGGY CODE ###

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

a = list(map(int,input().split()))

dp = [sys.maxsize]*n
dp[0] = 0
for i in range(n):
  for j in range(i+1,i+k+1):
    if j<n:
      dp[j]= min(dp[j],dp[i]+abs(a[i]-a[j]))
      
      
print(dp[n-1])


### FIXED CODE ###

import sys
n,k = map(int,input().split())
a = list(map(int,input().split()))

dp = [sys.maxsize]*n
dp[0]=0

#print(dp)
for i in range(n):
  for j in range(i+1,i+k+1):
    if j<n:
      dp[j] = min(dp[j],dp[i]+abs(a[i]-a[j]))
  #print(dp)
      
print(dp[n-1])
### BUGGY CODE ###

n = int(input())
A = list(map(int, input().split()))

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

ans = 0
L = [0]
R = [0]
for i in range(n-1):
    l = gcd(L[-1], A[i])
    L.append(l)
    r = gcd(R[-1], A[::-1][i])
    R.append(r)
for l, r in zip(L,R[::-1]):
    ans = max(ans, gcd(l, r))
print(ans)

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

ans = 0
L = [0]*(n)
R = [0]*(n+1)
for i in range(n-1):
    L[i+1] = gcd(L[i], A[i])
    R[i+1] = gcd(R[i], A[-i-1])
for l, r in zip(L[::-1],R):
    ans = max(ans, gcd(l, r))
print(ans)
### BUGGY CODE ###

# coding=utf-8
N = int(raw_input())
A = map(int, raw_input().split())

candidates = []
A.sort()
for i in xrange(1, len(A) + 1):
    if A.count(A[-i]) > 1:
        candidates.append(A[-i])
        if len(candidates) == 4:
            break
if len(candidates) < 4:
    print 0
else:
    print candidates[1] * candidates[3]


### FIXED CODE ###

# coding=utf-8

def count(list, target, num):
    l = len(list)
    c = 0
    for i in xrange(-num, l + 1):
        if list[-i] == target:
            c += 1
            if c == 4:
                return c
        else:
            return c
    return c


N = int(raw_input())
A = map(int, raw_input().split())

candidates = []
A.sort()
t = -1
for i in xrange(0, N + 1):
    n = count(A, A[t], t)
    for m in range(n / 2):
        candidates.append(A[t])
        if len(candidates) == 4:
            break
    t -= n
    if t < -N:
        break
if len(candidates) < 2:
    print 0
else:
    print candidates[0] * candidates[1]
### BUGGY CODE ###

n = int(input());

a = list(map(int, input().split()));

ok = True;
ans = 1;
for val in a:
    ans *= val;

if(ans > 1e18):
    ok = False;
if(ok):
    print(ans);
else:
    print(-1);


### FIXED CODE ###

n = int(input());

a = list(map(int, input().split()));

ok = True;
ans = 1;
a.sort();
for val in a:
    ans *= val;
    if(ans > 1e18):
        ok = False;
        break;
    elif(ans == 0):
        break;

if(ok):
    print(ans);
else:
    print(-1);
### BUGGY CODE ###

n = int(input())
S = input()

nums = set()
from itertools import combinations
for c in combinations(list(range(n)), 3):
    ss = S[c[0]]  + S[c[1]]  + S[c[2]]
    nums.add(ss)

print(len(nums))


### FIXED CODE ###

n = int(input())
S = input()
ans = 0
nums = list(map(str, range(10)))
for i in nums:
    s1 = S.find(i)
    if s1 < 0:
        continue
    for j in nums:
        s2 = S.find(j, s1+1)
        if s2 < 0:
            continue
        for k in nums:
            s3 = S.find(k, s2+1)
            if s3 > 0:
                ans += 1
print(ans)
### BUGGY CODE ###

from collections import deque
H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
Ch, Cw, Dh, Dw = Ch - 1, Cw - 1, Dh - 1, Dw - 1
maze = [list(input()) for i in range(H)]
#print(maze)
  
ans = [[-1] * W for i in range(H)]  
ans[Ch][Cw] = 0
q = deque([[0, Ch, Cw]])  
one = [[0, 1], [0, -1], [1, 0], [-1, 0]]
two = [[2, 2], [2, 1], [2, 0], [2, -1], [2, -2], [1, 2], [1, 1], [1, -1], [1, -2], [0, 2], [0, -2], [-1, 2], [-1, 1], [-1, -1], [-1, -2], [-2, 2], [-2, 1], [-2, 0], [-2, -1], [-2, -2]] 
while q:
  cnt, h, w = q.popleft()
  if ans[h][w] < cnt:
    continue
  for i, j in one:
    if (0 <= h + i < H) and (0 <= w + j < W) and (maze[h + i][w + j] != "#"):
        if ans[h + i][w + j] == -1 or ans[h + i][w + j] > cnt:
          ans[h + i][w + j] = cnt
          q.appendleft([cnt, h + i, w + j])
  for i, j in two:  
    if (0 <= h + i < H) and (0 <= w + j < W) and (maze[h + i][w + j] != "#"):
        if ans[h + i][w + j] == -1 or ans[h + i][w + j] > cnt + 1:
          ans[h + i][w + j] = cnt + 1
          q.appendleft([cnt + 1, h + i, w + j])
              
print(ans[Dh][Dw])              
          
              
          
          
    
    
    

  


### FIXED CODE ###


H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
Ch, Cw, Dh, Dw = Ch - 1, Cw - 1, Dh - 1, Dw - 1
maze = [list(input()) for i in range(H)]
#print(maze)
  
ans = [[-1] * W for i in range(H)]  
ans[Ch][Cw] = 0
from collections import deque
q = deque([[0, Ch, Cw]])  
one = [[0, 1], [0, -1], [1, 0], [-1, 0]]
two = [[2, 2], [2, 1], [2, 0], [2, -1], [2, -2], [1, 2], [1, 1], [1, -1], [1, -2], [0, 2], [0, -2], [-1, 2], [-1, 1], [-1, -1], [-1, -2], [-2, 2], [-2, 1], [-2, 0], [-2, -1], [-2, -2]] 
while q:
  cnt, h, w = q.popleft()
  if ans[h][w] < cnt:
    continue
  for i, j in one:
    if (0 <= h + i < H) and (0 <= w + j < W) and (maze[h + i][w + j] != "#"):
        if ans[h + i][w + j] == -1 or ans[h + i][w + j] > cnt:
          ans[h + i][w + j] = cnt
          q.appendleft([cnt, h + i, w + j])
  for i, j in two:  
    if (0 <= h + i < H) and (0 <= w + j < W) and (maze[h + i][w + j] != "#"):
        if ans[h + i][w + j] == -1 or ans[h + i][w + j] > cnt + 1:
          ans[h + i][w + j] = cnt + 1
          q.append([cnt + 1, h + i, w + j])
              
print(ans[Dh][Dw])
### BUGGY CODE ###

from scipy.sparse.csgraph import csgraph_from_dense,dijkstra

N = int(input())
edge = [ [10**9+1 for j in range(N+1)] for i in range(N+1) ]

for i in range(N-1):
  a,b,c = map(int,input().split())
  edge[a][b] = c
  edge[b][a] = c
  
Q,K = map(int,input().split())

G = csgraph_from_dense(edge, null_value=10**9+1)
d = dijkstra(G,indices = K)

for i in range(Q):
  x,y = map(int,input().split())
  print(int(d[x]+d[y]))

### FIXED CODE ###

from collections import deque

N = int(input())

gr = { i:[] for i in range(N+1)}

for i in range(N-1):
  a,b,c = map(int,input().split())
  gr[a].append([b,c])
  gr[b].append([a,c])  
  
Q,K = map(int,input().split())

sta = deque([K])
dis = [10**10 for i in range(N+1)]
dis[K] = 0
sumi = [-1 for i in range(N+1)]

while len(sta) >= 1:
  a = sta.pop()
  sumi[a] += 1
  
  for j in gr[a]:
    if sumi[ j[0] ] != -1:
      continue
    else:
      sta.append(j[0])
      dis[j[0]] = dis[a] + j[1]
    
for i in range(Q):
  x,y = map(int,input().split())
  
  print(int(dis[x] + dis[y] ))
### BUGGY CODE ###

H, W = map(int, input().split())
S = []
for _ in range(H):
    s = input()
    S.append(s)
    
import copy
maze = copy.deepcopy(S)

import queue

INT_MAX = 2**63-1
stayed = [[INT_MAX] * W for _ in range(H)]

def bfs():
    gole = (W-1, H-1)
    q = queue.Queue()
    q.put((
        0, # current x
        0, # current y
        0, # count
    ))

    while q:
        cur_x, cur_y, cnt = q.get()
        if (cur_x, cur_y) == gole:
            return cnt
        
        next_pos = [
            (cur_x, cur_y-1),
            (cur_x, cur_y+1),
            (cur_x-1, cur_y),
            (cur_x+1, cur_y)
        ]
        
        for x, y in next_pos:
            if x == -1 or y == -1 or x == W or y == H:
                continue
            if S[y][x] == '#':
                continue
            if stayed[y][x] > cnt+1:
                stayed[y][x] = cnt+1
                q.put((x, y, cnt+1))
    return -1
            

shortest_path_len = bfs()

if shortest_path_len != -1:
    cnt_dot = sum([s.count('.') for s in maze])


    ans = cnt_dot - shortest_path_len - 1
    print(ans)
else:
    print(-1)
        
        
        

### FIXED CODE ###

H, W = map(int, input().split())
S = []
for _ in range(H):
    s = input()
    S.append(s)
    
import copy
maze = copy.deepcopy(S)

import queue

INT_MAX = 2**63-1
stayed = [[INT_MAX] * W for _ in range(H)]

def bfs():
    gole = (W-1, H-1)
    q = queue.Queue()
    q.put((
        0, # current x
        0, # current y
        0, # count
    ))

    while not q.empty():
        cur_x, cur_y, cnt = q.get()
        if (cur_x, cur_y) == gole:
            return cnt
        next_pos = [
            (cur_x, cur_y-1),
            (cur_x, cur_y+1),
            (cur_x-1, cur_y),
            (cur_x+1, cur_y)
        ]
        
        for x, y in next_pos:
            if x == -1 or y == -1 or x == W or y == H:
                continue
            if S[y][x] == '#':
                continue
            if stayed[y][x] > cnt+1:
                stayed[y][x] = cnt+1
                q.put((x, y, cnt+1))
                
        #print(stayed)
    return -1
            

shortest_path_len = bfs()

if shortest_path_len != -1:
    cnt_dot = sum([s.count('.') for s in maze])


    ans = cnt_dot - shortest_path_len - 1
    print(ans)
else:
    print(-1)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
x=[]
if n>=3:
  for i in range(1,n-1):
    x.append(a.count(i)+a.count(i-1)+a.count(i+1))
  print(max(x))
elif n==1:
    print(1)
elif n ==2:
  if abs(a[0]-a[1])<=1:
    print(2)
  else:
    print(1)
    

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
z = 100002*[0]

for a in A:
  z[a]+=1
  z[a+1]+=1
  z[a+2]+=1

print(max(z))
### BUGGY CODE ###

N = int(input())

P_list = input().split()

P_list_int = [int(p) for p in P_list]


correct_cnt = 0
for i in range(N):
    for j in range(i+1):
        if(P_list_int[i]>P_list_int[j]):
            break

        if(j == i):
            correct_cnt += 1

print(correct_cnt)

### FIXED CODE ###

N = int(input())

P_list = input().split()

P_list_int = [int(p) for p in P_list]


correct_cnt = 0
min_val = 200000
for i in range(N):
    if(P_list_int[i] <= min_val):
        min_val = P_list_int[i]
        correct_cnt += 1

print(correct_cnt)
### BUGGY CODE ###

a=input()
a = list(map(int, input().split()))
count=0
tmp=0
for i in a[:-1]:
    for j in a[count+1:]:
        tmp=(tmp+i*j)%(10**9+7)
    count+=1
print(tmp)

### FIXED CODE ###

import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
s=[0]*(n-1)
tmp=0
for i in range(n-1):
    tmp=(tmp+a[(i+1)*-1])%(10**9+7)
    s[(i+1)*-1]=tmp
    
print(int((s*a[:-1]%(10**9+7)).sum()%(10**9+7)))
### BUGGY CODE ###

#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

S = str(input())
N = len(S)
count = 1
now = 1
temp = S[0]
while now<=N-1:
    if now == N-1:
        if temp == S[N-1]:
            break
        else:
            count += 1
            break
    for i in range(now+1,N):
        if S[now:i] != temp:
            count += 1
            temp = S[now:i]
            now = i
            break
print(count)

### FIXED CODE ###

#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

S = str(input())
N = len(S)
count = 1
now = 1
temp = S[0]
while now<=N-1:
    if now == N-1:
        if temp == S[N-1]:
            break
        else:
            count += 1
            break
    for i in range(now+1,N+1):
        if S[now:i] != temp:
            count += 1
            temp = S[now:i]
            now = i
            break
print(count)
### BUGGY CODE ###

n = int(input().strip())
a = [int(input().strip()) for _ in range(n)]
visited = [False] * n
visited[0] = True
now = 0
ans = 0
while True:
    now = a[now] - 1
    ans += 1
    if now == 1:
        print(ans)
        exit()
    elif visited[now]:
        print(-1)
        exit()


### FIXED CODE ###

n = int(input().strip())
a = [int(input().strip()) for _ in range(n)]
visited = [False] * n
visited[0] = True
now = 0
ans = 0
while True:
    now = a[now] - 1
    ans += 1
    if now == 1:
        print(ans)
        exit()
    elif visited[now]:
        print(-1)
        exit()
    visited[now] = True
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import math


def gcd(a, b, c):
    temp = math.gcd(a, b)
    return math.gcd(temp, c)


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

    total = 0
    temp = {}
    for i in range(1, k + 1):
        for j in range(1, k + 1):
            for l in range(1, k + 1):
                join_str = "".join(sorted([str(i).zfill(3), str(j).zfill(3), str(l).zfill(3)]))
                gcd_val = temp.get(join_str, 0)
                if gcd_val == 0:
                    gcd_val = gcd(i, j, l)
                total += gcd_val

    return total


if __name__ == '__main__':
    print(main())


### FIXED CODE ###

# -*- coding: utf-8 -*-
import math


def gcd(a, b, c):
    temp = math.gcd(a, b)
    return math.gcd(temp, c)


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

    total = 0
    temp = {}
    for i in range(1, k + 1):
        for j in range(1, k + 1):
            for l in range(1, k + 1):
                # join_str = "".join(sorted([str(i).zfill(3), str(j).zfill(3), str(l).zfill(3)]))
                # gcd_val = temp.get(join_str, 0)
                # if gcd_val == 0:
                gcd_val = gcd(i, j, l)
                total += gcd_val

    return total


if __name__ == '__main__':
    print(main())
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
list=[0]*(N-1)
list1=[0]*N
for i in range(1,N):
    list[i-1]=A[i-1]

for j in range(N-1):
    for k in range(N):
        if list[j]==k+1:
            list1[k]+=1
for l in range(N):
    print(list1[l])

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
list=[0]*(N-1)
list1=[0]*N
for i in range(1,N):
    list[i-1]=A[i-1]
    list1[A[i-1]-1]+=1
list1.append(0)
for j in range(N):
    print(list1[j])
### BUGGY CODE ###

import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

n, = map(int, input().split())
data = getInputListInt()

param = []

tmp = 0
for i in range(n):
    if param.count(data[i])==0:
        param.append(data[i])

if len(param)==1:
    param.append(0)

ans = sys.maxsize

for i in range(len(param)):
    one = param[i]
    for j in range(len(param)):
        if i == j:
            continue

        two = param[j]
        cnt = 0
        for k in range(n):
            if k % 2 == 0:
                if data[k] != one:
                    cnt+=1
            else:
                if data[k] != two:
                    cnt+=1

        ans = min(ans, cnt)

print(ans)



### FIXED CODE ###

import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

n, = map(int, input().split())
data = getInputListInt()

onedic = {0:0}
twodic = {0:0}

for i in range(n):
    if i % 2 ==0:
        onedic[data[i]]=0
    else:
        twodic[data[i]]=0

for i in range(n):
    if i % 2 ==0:
        onedic[data[i]]+=1
    else:
        twodic[data[i]]+=1

onemax = max(onedic, key=onedic.get)
twomax = max(twodic, key=twodic.get)

onemax = sorted(onedic.items(), key = lambda x:x[1], reverse=True)
twomax = sorted(twodic.items(), key = lambda x:x[1], reverse=True)

ans = 0
if onemax[0][0] != twomax[0][0]:
    ans = n - onemax[0][1] - twomax[0][1]
else:
    ans = min(n - onemax[0][1] - twomax[1][1], n - onemax[1][1] - twomax[0][1])

print(ans)
### BUGGY CODE ###

list_l = []
list_R = []
ID,gate = map(int,input().split())
s = 0
t = 0
for i in range(gate):
  l,r = map(int,input().split())
  list_l.append(l)
  list_R.append(r)

for i in range(ID+1):
  for j in range(gate):
    if list_l[j] <= i <= list_R[j]:
      s += 1
    else:
      None
  if s == gate:
    t += 1
  s = 0
print(t)


### FIXED CODE ###

list_l = []
list_R = []
ID,gate = map(int,input().split())
s = 0
for i in range(gate):
  l,r = map(int,input().split())
  list_l.append(l)
  list_R.append(r)
a = max(list_l)
b = min(list_R)

for i in range(ID+1):
  if a <= i <= b:
    s += 1
  else:
    None
print(s)
### BUGGY CODE ###

import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    K = ii()

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

    for i in range(K + 1):
        if ret[i] % K == 0:
            print(i + 1)
            exit()
    else:
        print(-1)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    K = ii()

    ret = []
    for i in range(K + 1):
        if i == 0:
            ret.append(7 % K)
        else:
            ret.append((ret[i - 1] * 10 + 7) % K)
    for i in range(K + 1):
        if ret[i] == 0:
            print(i + 1)
            exit()
    else:
        print(-1)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

n = input()
s = 0
for i in n:
  s += int(n)
if s % 9 == 0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n = input()
s = 0
for i in range(len(n)):
  s += int(n[i])
if s % 9 == 0:
  print('Yes')
else:
  print('No')