Harryxun/stf_run huggingface dataset:
i = list(map(int, input().split()))
j = [int(0)] * 9
 
n=i[9]
 
for b in range(9):
    for c in range(n):
        if i[b]==i[10+c]:
            j.insert(b,1)    
 
if  j[0]==1 and j[3]==1 and j[6]==1\
or j[1]==1 and j[4]==1 and j[7]==1\
or j[2]==1 and j[5]==1 and j[8]==1\
or j[0]==1 and j[1]==1 and j[2]==1\
or j[3]==1 and j[4]==1 and j[5]==1\
or j[6]==1 and j[7]==1 and j[8]==1\
or j[0]==1 and j[4]==1 and j[8]==1\
or j[2]==1 and j[4]==1 and j[6]==1:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

#import numpy as np

i=[input().split() for l in range(4)]

n=int(i[3][0])

j = [input() for i in range(n)]

#i=np.array(i)
#print(i)


k = [['0' for o in range(3)] for p in range(3)]

for b in range(3):
    #print('b:',b)
    for c in range(3):
        #print('c:',c)
        for d in range(n):
            #print('d:',d)
            if i[b][c]==j[d]:
                k[b][c]='1'
                #print('書き換えたよ',k)
                
                
#print(i)
#print(j)
#print(k)


if  k[0][0]=='1' and k[0][1]=='1' and k[0][2]=='1'\
or k[1][0]=='1' and k[1][1]=='1' and k[1][2]=='1'\
or k[2][0]=='1' and k[2][1]=='1' and k[2][2]=='1'\
or k[0][0]=='1' and k[1][0]=='1' and k[2][0]=='1'\
or k[0][1]=='1' and k[1][1]=='1' and k[2][1]=='1'\
or k[0][2]=='1' and k[1][2]=='1' and k[2][2]=='1'\
or k[0][0]=='1' and k[1][1]=='1' and k[2][2]=='1'\
or k[2][0]=='1' and k[1][1]=='1' and k[0][2]=='1':
	print('Yes')
else:
    print('No')
import numpy as np
import bisect
N,M=map(int,input().split())
A=np.array(list(map(int,input().split())))
JinA=[]
for i in range(M):
    b,c=map(int,input().split())
    JinA.append((c,b))

JinA.sort(reverse=True)

A.sort()
len_b=0
new_list=[]
for c,b in JinA:
    add_b=min(b,N-len_b)
    new_list+=[c]*add_b
    if add_b==0:
        break
new_list+=[0]*(N-len(new_list))
now=np.array(new_list)    
Ans=np.maximum(A,now)
print(Ans.sum())

### FIXED CODE ###

from operator import itemgetter

N, M = list(map(int, input().split()))
A = [[1, a] for a in list(map(int, input().split()))]
BC = [list(map(int, input().split())) for i in range(M)]

q = sorted(A+BC, key=itemgetter(1), reverse=True)

ans = 0
i = 0

while N:
    n = min(q[i][0], N)
    ans += q[i][1] * n
    N -= n
    i += 1
print(ans)
# import numpy as np
import sys, math, heapq
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

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

rcA = [0] * (N)
rcA[-1] = A[-1]
for i in range(1, N):
    rcA[-i - 1] = rcA[-i] + A[-i - 1]
# print(rcA)

cnt = 1
node = 1
for a, rca in zip(A, rcA):
    min_node = node - a
    max_node = 2 * (node - a)
    if rca < min_node:
        print(-1)
        exit()
    node = min(max_node, rca)
    cnt += node
print(cnt)

### FIXED CODE ###

# import numpy as np
import sys, math, heapq
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

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

if N == 0:
    if A[0] == 1:
        print(1)
        exit()
    else:
        print(-1)
        exit()
if N != 0 and A[0] > 0:
    print(-1)
    exit()

rcA = [0] * (N)
rcA[-1] = A[-1]
for i in range(1, N):
    rcA[-i - 1] = rcA[-i] + A[-i - 1]
# print(rcA)

cnt = 1
node = 1
for a, rca in zip(A, rcA):
    min_node = node - a
    max_node = 2 * (node - a)
    if rca < min_node or min_node < 0:
        print(-1)
        exit()
    node = min(max_node, rca)
    # print(node)
    cnt += node
if node != A[-1]:
    print(-1)
    exit()
print(cnt)
n = int(input())
res = 0
sboth = 0
sa = 0
sb = 0
for i in range(n):
    s = input()
    res += s.count("AB")
    if s[0] == "B" and s[-1] == "A":
        sboth += 1
        continue
    if s[0] == "B":
        sb += 1
        continue
    if s[-1] == "A":
        sa += 1
        continue

num = min(sboth)
res += num
sboth -= num

num = min(sboth, sb)
res += num
sboth -= num

num = min(sa, sb)
res += num
sa -= num
sb -= num

num = min(sboth)
res += num
sboth -= num

num = min(sboth, sb)
res += num
sboth -= num

num = min(sa, sb)
res += num
sa -= num
sb -= num


if sboth > 0:
    sboth = 1
    res += sboth - 1

print(res)



### FIXED CODE ###

n = int(input())
res = 0
numa = numb = numboth = 0
for _ in range(n):
    s = input()
    res += s.count("AB")
    if s[0] == "B" and s[-1] == "A":
        numboth += 1
    elif s[0] == "B":
        numb += 1
    elif s[-1] == "A":
        numa += 1

#print(numboth, numa, numb)
#print(res)

if numboth == 0:
    res += min(numa, numb)
else:
    if numa == 0 and numb == 0:
        res += numboth - 1
    else:
        res += numboth
        res += min(numa, numb)
print(res)
n = int(input())
a = [int(i) for i in input().split()]
x = 0
for j in range(0,n):
  if not (((a[j] % 2) == 0) and (((a[j] % 3) != 0) or (a[j] % 5 != 0))):
    x = 1
if x == 1:
  print('APPROVED')
else:
  print('DENIED')

### FIXED CODE ###

x, y, z = input().split()
if x == y:
  if x == z and y == z:
    print("No")
  else:
    print("Yes")
elif x == z:
  if x == y and y == z:
    print("No")
  else:
    print("Yes")
elif y == z:
  if x == y and x == z:
    print("No")
  else:
    print("Yes")
else:
  print("No")
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

S = IS()
if S[0] == "A" and S[2] == "C" and islower(S[1])==True  and islower(S[3:]):
    print("AC")
else:
    print("WA")


### FIXED CODE ###

#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

S = IS()
if S[0] == "A" and S.count("C") == 1 and S[-1] != "C":
    if S[1].islower() == True:
        if S[S.index("C")+1:].islower() == True:
            print("AC")
        else:
            print("WA")
    else:
        print("WA")
else:
    print("WA")
n,m = map(int,input().split())
para = [int(input()) for i in range(m)]
mod = 10**9+7


dp = [-1]*(n+1)
dp[0] = 1
for i in para :
    dp[i] = 0

def dps(cnt,cantvisit):
    if cnt == n + 1 :
        return 

    else :
        if cnt == 1 :
            if cnt in cantvisit :
                dp[1] = 0
                cnt += 1
            else : 
                dp[1] = 1
                cnt += 1
        else :
            if dp[cnt] != 0 :  
                dp[cnt] = (dp[cnt-1] + dp[cnt-2]) % mod
                cnt += 1
            else :
                cnt += 1
        return dps(cnt,cantvisit)
dps(1,para)
print("{}".format(dp[-1]%mod))

### FIXED CODE ###

n,m = map(int,input().split())
para = [int(input()) for i in range(m)]
mod = 10**9+7
dp = [-1]*(n+1)
for i in para:
    dp[i] = 0
for i in range(n+1):
    if  dp[i] != 0 :
        if i == 1 or i==0:
            dp[i] = 1
        else:
            dp[i] = (dp[i-1] + dp[i-2])%mod



print("{}".format(dp[-1]))
a,b=map(int,input().split())
if a*b % 2 = 0:
  print("Even")
else:
  print("Odd")
    
 

### FIXED CODE ###

a, b = map(int, input().split())
if a*b % 2 == 0:
    print('Even')
else:
    print('Odd')
k = int(input())
a[i] = [1, 2, 3, 4, 5, 6, 7, 8, 9]

for i in range(k):
    if a[i] % 10 != 0:
        a.append(10*a[i] + a[i] % 10 - 1)
    a.append(10*a[i] + a[i] % 10)
    if a[i] % 10 != 9:
        a.append(10*a[i] + a[i] % 10 + 1)

print(a[k - 1])


### FIXED CODE ###

k = int(input())
a = [1, 2, 3, 4, 5, 6, 7, 8, 9]

for i in range(k):
    if a[i] % 10 != 0:
        a.append(10*a[i] + a[i] % 10 - 1)
    a.append(10*a[i] + a[i] % 10)
    if a[i] % 10 != 9:
        a.append(10*a[i] + a[i] % 10 + 1)

print(a[k - 1])
from scipy.special import comb
n,k = map(int, input().split())
mod = 10**9+7
# a = comb(n, r)
for i in range(1,k+1):
    if n-k+1 < i:
        print(0)
    else:
        a = comb(n-k+1,i,exact=True)
        print((a*(i**(k-i)))%mod)

### FIXED CODE ###

n,k = map(int, input().split())
mod = 10**9+7
from scipy.misc import comb

for i in range(1,k+1):
    print((comb(n-k+1,i,exact=True)*comb(k-1,i-1,exact=True))%mod)
α　= input()
if α.isupper():
    print('A')
else:
    print('a')

### FIXED CODE ###

a = input()
print('A' if a.isupper() else 'a')
import sys
s = sys.stdin.readlines().lower()
for i in 'abcdefghijklmnopqrstuvwxyz':
    print(i, ":", s.count(i))


### FIXED CODE ###

import sys
from collections import Counter
m = Counter(sys.stdin.read().lower())
for i in 'abcdefghijklmnopqrstuvwxyz':
    print(i, ":", m[i])
import sys
from collections import deque
from numba import jit

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

@jit
def gg(nn, x, y, n, is_sit):
	q = deque()
	q.append(1000*x+y)
	cl = set()
	cl.add(x*1000+y)
	while q:
		v = q.popleft()
		x,y = v//1000, v %1000
		nn[x][y] -= 1
		k = nn[x][y]
		for dx,dy in ([-1,0], [0,-1], [1,0], [0,1]):
			if x+dx < 0 or x +dx >= n or y + dy < 0 or y + dy >= n:
				continue
			if nn[x+dx][y + dy] <= k + is_sit[x+dx][y+dy]:
				continue
			if (x+dx)*1000+(y+dy) in cl:
				continue
			q.append((x+dx)*1000+ (y+dy))
			cl.add((x+dx)*1000 + (y+dy))
		#print('yyyyyy')
		#for l in nn:
		#	print(l)

def main():
	n = int(input())
	nn = [[(n+1)//2] * n for _ in range(n)]
	is_sit = [[1] * n for _ in range(n)]
	for i in range(n):
		for j in range(n):
			nn[i][j] = min(i+1,j+1,n-i,n-j)
	#for l in nn:
	#	print(l)
	
	#b , c = tin()
	pl = lin()
	ans = 0
	for p in pl:
		x, y = (p-1) // n, (p-1) % n
		ans += nn[x][y]-1
		is_sit[x][y] = 0
		gg(nn, x, y, n, is_sit)
		
	print(ans)
	#s = input()
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

### FIXED CODE ###

import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

#+++++

def main():
	n = int(input())
	nn = [[min(i,j,n-i-1,n-j-1) for j in range(n)] for i in range(n)]
	is_sit = [[True] * n for _ in range(n)]
	cc = [[0]*n for _ in range(n)]
	
	#b , c = tin()
	pl = list(map(int, input().split()))
	ans = 0
	for p in pl:
		x, y = (p-1) // n, (p-1) % n
		ans += nn[x][y]
		is_sit[x][y] = False
		q = [(x, y, nn[x][y])]
		while q:
			(x, y, v) = q.pop()
			if x >= 0 and nn[x-1][y]>v:
				nn[x-1][y] = v
				q.append((x-1, y, v+is_sit[x-1][y]))
			if x < n-1 and nn[x+1][y]>v:
				nn[x+1][y] = v
				q.append((x+1, y, v+is_sit[x+1][y]))		
			if y >= 0 and nn[x][y-1]>v:
				nn[x][y-1] = v
				q.append((x, y-1, v+is_sit[x][y-1]))
			if y < n-1 and nn[x][y+1]>v:
				nn[x][y+1] = v
				q.append((x, y+1, v+is_sit[x][y+1]))	
		
	print(ans)
	#s = input()	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)
import heapq
N, A = map(int, input().split())
X = [int(x) - A for x in input().split()]
for x in X:
  if x > 0:
    Xp.append(x)
  elif x < 0:
    Xm.append(-x)
  else:
    X0.append(x)
limit = min(sum(Xp), sum(Xm))
Xp = [x for x in Xp if x <= limit]
Xm = [x for x in Xm if x <= limit]
R = [[0, 0] for x in range(limit + 1)]
def c(X, k):
  Q = []
  heapq.heappush(Q, 0)
  for x in X:
    _Q = []
    while Q:
      q = heapq.heappop(Q)
      if q > limit:
        break
      heapq.heappush(_Q, q)
      heapq.heappush(_Q, q + x)
    Q = _Q
  while Q:
    q = heapq.heappop(Q)
    if q > limit:
      break
    R[q][k] += 1
c(Xp, 0)
c(Xm, 1)
print(sum([r[0] * r[1] for r in R]) * (2 ** len(X0)) - 1)

### FIXED CODE ###

from collections import Counter
N, A = map(int, input().split())
X = [int(x) - A for x in input().split()]
C = Counter([0])
for x in X:
  tmp = Counter()
  for i, c in C.items():
    tmp[i + x] += c
  C += tmp
print(C[0] - 1)
t = ""
s = input()
for i in s:
  if i == 'B' and len(t) > 0:
    t.pop()
  else:
    t.append(i)
print(t)

### FIXED CODE ###

s = input()
count = ''
for i in s:
  if i == 'B':
    if len(count) != 0:
    	count = count[:-1]
  else:
    count += i
print(count)
N, K = map(int,input().split())
p = list(map(int,input().split()))
c = list(map(int,input().split()))
K = K-1
ans = -10**9-1
for h in range(N):
   i += 1
   start = i
   circle = [c[i-1]]
   i = p[i-1]
   while i != start:
      l = len(circle)
      score = circle[l-1] + c[i-1]
      circle.append(score)
      i = p[i-1]
   l=len(circle)
   for j in range(min(l, K+1)):
      if circle[l-1] > 0:
         score = circle[j] + ((K - j)//l)*circle[l-1]
      else:
         score = circle[j]
      ans = max(score, ans)      
print(ans)

### FIXED CODE ###

N, K = map(int,input().split())
p = list(map(int,input().split()))
c = list(map(int,input().split()))
K = K-1
ans = -10**9-1
for h in range(N):
   i = h+1
   start = i
   circle = [c[i-1]]
   i = p[i-1]
   while i != start:
      score = circle[-1] + c[i-1]
      circle.append(score)
      i = p[i-1]
   l=len(circle)
   for j in range(min(l, K+1)):
      if circle[l-1] > 0:
         score = circle[j] + ((K - j)//l)*circle[l-1]
      else:
         score = circle[j]
      ans = max(score, ans)      
print(ans)
n = int(input())
a = []
z =0

for i in range(1, n+1, 2):
    b = n//i
    c = n%i
    if b==c:
        a.append(i)
print(sum(a))

### FIXED CODE ###

n = list(map(int, input().split()))
a =[]
c = 1
b = []

for i in range(1, n[0]+1):
    b.append(i)

for j in range(1, n[1]+1):
    a.append(j)

for k in range(b[-1]):
    if b[-1] == a[-1]:
        print(c)
        break
    else:
        a[-1] += 1
        c += 1
from math import ceil
a, b = map(int, input())
print(ceil((a + b) / 2))


### FIXED CODE ###

from math import ceil
a, b = map(int, input().split())
print(ceil((a + b) / 2))
from math import floor
n = int(input())
a = int(input())
b = int(input())

print(ceil(n / a) * ceil(n / b))

### FIXED CODE ###

from math import ceil
n = int(input())
a = int(input())
b = int(input())
print((n - a + 1) * (n - b + 1))
N = int (input())
H = list(map(int,input().split()))
ans = 'Yes'
for  i in range(N-1):
    diff = H[i+1] - H[i]
    if diff >= 1:
        H[i+1] -= 1
    elif diff < 0:
        ans ='No'
print(ans)


### FIXED CODE ###

a,b,c = map(int,(input().split()))
ans = c-(a-b)
if ans <= 0:
    ans = 0
else:
    pass
print(ans)
s = input()
n = len(s)
if n%2==1 or s[:n/2]==s[n/2:]:
    print("No")
else:
    print("Yes")
return 0

### FIXED CODE ###

n = int(input())
s = input()
if n%2==1 or s[:n//2]!=s[n//2:] :
    print("No")
else:
    print("Yes")
x,y=map(int,input().split())
if 0<=x<=y or x<=0<=y<=-x or x<=y<=0:
    print(y-x)
elif y<=-x<=0<=x:
    print(-y-x+1)
elif y<=x<=0 or o<=y<=x:
    print(x-y+2)
else:
    print(y+x+1)

### FIXED CODE ###

x,y=map(int,input().split())
cnt=0
if x<0<y or y<=0<=x:
    cnt=1
elif 0<y<x or y<x<0:
    cnt=2
print(abs(abs(x)-abs(y))+cnt)
N,M = map(int,input().split())
A,B = map(int,input().split())

count = 1

for i in range(N):
   
      
    if  count == A or B:
        count += 0
    else:
       count += 1 
    
print(count)

### FIXED CODE ###

K = int(input())



for i in range(K):

  print("ACL", end='')
n=int(input())
a=[int(i) for i in input().split()]
if(len(set(a)==n)):
    print('YES')
else:
    print('NO')

### FIXED CODE ###

n=int(input())
a=[int(i) for i in input().split()]
if(len(set(a))==n):
    print('YES')
else:
    print('NO')
# N個のロボット
N = int(input())

# 1個前
rem = 0
bx = 0
bl = 0
for i in range(N):
    x,l = map(int, input().split())
    
    #print(x,l, bx,bl)
    
    # 1個前と重複確認
    if i != 0:
        rn = list(range(x+l-1, x-l, -1 ))
        before = list(range(bx+bl-1, bx-bl, -1 ))
        #print(rn)
        #print(before)
        if len(set(rn) & set(before)) != 0:
            #print("rem")
            rem +=1
            # 1個前は変えないで次へ
            continue
        else:
            # 1個前を更新
            bx = x
            bl = l
    else:
        # 1個前を更新
        bx = x
        bl = l
    

print(N-rem)

### FIXED CODE ###

N = int(input())
robots = [tuple(map(int,input().split())) for _ in range(N)]

#print(robots)
# 最大値と最小値を計算する
robots = [(x+l,x-l) for x,l in robots]
#print(robots)
# ソートする
robots.sort()
#print(robots)

cnt = 0
last = -float('inf')
for r,l in robots:
    #print(last, l, r)
    # 1個前の最大値を、今回の最小値が上回っていたらOK
    if last <= l:
        cnt += 1
        # 次の最大値を更新する
        last = r

print(cnt)
inputStr = input().split()
intA = int(inputStr[0])
intB = int(inputStr[1])
intX = int(inputStr[2])

intN = 0
sum = 0

while(sum < intX):
  sum = intA * intN + intB * len(str(intN))
  intN+=1

print(intN - 2)

### FIXED CODE ###

str = input()
if str == 'SUN':
  print(7)
elif str == 'MON':
  print(6)
elif str == 'TUE':
  print(5)
elif str == 'WED':
  print(4)
elif str == 'THU':
  print(3)
elif str == 'FRI' :
  print(2)
elif str == 'SAT':
  print(1)
from itertools import product as p
A,B,C,D=input();o="+-"
for x in map("".join,p(A,o,B,o,C,o,D)):if eval(x) == 7:print(x+"=7");break

### FIXED CODE ###

from itertools import product

A, B, C, D = [x for x in input().strip()]

for x in ["".join(x) for x in product(A, '+-', B, '+-', C, '+-', D)]:
    if eval(x) == 7:
        print(x+"=7")
        break
v

### FIXED CODE ###

N = int(input())
ans = 0
for A in map(int, input().split()):
	ans += 1 / A

ans = 1 / ans
print(ans)
n, m = map(int, input().split())
a = sorted(map(int, input().split()))[::-1]
i = 0
for j in range(n):
    i = i + a[j]
x = i / (4 * m)
print("Yes" if a[m] >= x else "No")

### FIXED CODE ###

n, m = map(int, input().split())
a = sorted(map(int, input().split()))[::-1]
i = 0
for j in range(n):
    i = i + a[j]
x = i / (4 * m)
print("Yes" if a[m - 1] >= x else "No")
import numpy as np

N,  = map(int, input().split())
A = np.array(list((map(int, input().split()))))


thr = 10**18

res = np.prod(A)

if res > thr:
    res = -1

print(int(res))


### FIXED CODE ###

# coding: utf-8

#import numpy as np

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

thr = 10**18

res = 1

if 0 in A:
    res = 0
else:
    for a in A:

        res *= a

        if res > thr:
            res = -1
            break

print(int(res))
from collections import deque
H, W = map(int ,input().split())
A = [input() for _ in range(H)]
dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
inf = float("inf")

dp = [[inf]*W for _ in range(H)]
q = deque()
for y, row in enumerate(A):
    for x, c in enumerate(row):
        if c == "#":
            dp[y][x] = 0
            q.append((x, y))

while q:
    x, y = q.popleft()
    d = dp[x][y]
    for dx, dy in dxy:
        nx, ny = x+dx, y+dy
        if (not 0 <= nx < W) or (not 0 <= ny < H):
            continue
        if dp[ny][nx] <= d+1:
            continue
        dp[ny][nx] = d+1
        q.append((nx, ny))

print(max(max(row) for row in dp))



### FIXED CODE ###

from collections import deque
H, W = map(int ,input().split())
A = [input() for _ in range(H)]
dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
inf = float("inf")

dp = [[inf]*W for _ in range(H)]
q = deque()
for y, row in enumerate(A):
    for x, c in enumerate(row):
        if c == "#":
            dp[y][x] = 0
            q.append((x, y))

while q:
    x, y = q.popleft()
    d = dp[y][x]
    for dx, dy in dxy:
        nx, ny = x+dx, y+dy
        if (not 0 <= nx < W) or (not 0 <= ny < H):
            continue
        if dp[ny][nx] <= d+1:
            continue
        dp[ny][nx] = d+1
        q.append((nx, ny))

print(max(max(row) for row in dp))
a = int(input())
b, c = map(int, input().split())
s = input()
print(a+b+c, end = ' ')
print(s)


### FIXED CODE ###

t, x = map(int, input().split())
print(t/x)
n = int(input())
a = list(map(int, input().split()))
b = {}
for i in range(n):
  b.add((a[i], i+1))
for x,y in sorted(b):
  print(y, end=" ")
  

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
  b.append((a[i], i+1))
for x,y in sorted(b):
  print(y, end=" ")
# -*- coding: utf-8 -*-
 
import numpy as np
 
N = int(input())
 
A = np.array(list(map(int, input().split())))
mul = np.prod(A)
 
if mul > 1000000000000000000:
    print(-1)
    exit(-1)
print(mul)

### FIXED CODE ###

# -*- coding: utf-8 -*-

import numpy as np

N = int(input())

A = np.array(list(map(int, input().split())))

if 0 in A:
    print(0)
    exit(0)

mul = A[0]

if np.sum(A < 0) % 2 == 1:
    for i in A[1:]:
        mul *= i
else:
    for i in A[1:]:
        if 1000000000000000000 / i < mul:
            print(-1)
            exit(0)
        mul *= i

if mul > 1000000000000000000:
    print(-1)
    exit(0)

print(mul)
def exhaustive_search(start, Sum, answer):
    for i in range(start, n):
        Sum = Sum + A[i]
        if Sum == answer:
            return True
        elif Sum > answer:
            Sum = Sum - A[i]
            next
        else:
            r = exhaustive_search(i+1, Sum, answer)
            if r == True:
                return True
            else:
                Sum = Sum - A[i]
    return False


for i in M:
    r = exhaustive_search(0, 0, i)
    if r == True:
        print('yes')
    else:
        print('no')
print(?\n)

### FIXED CODE ###

def solve(dp, a, i, m):
  if m in dp[i]:
    return dp[i][m]

  if m == 0:
    dp[i][m] = True
  elif i >= len(a):
    dp[i][m] = False
  elif solve(dp, a, i+1, m):
    dp[i][m] = True
  elif solve(dp, a, i+1, m-a[i]):
    dp[i][m] = True
  else:
    dp[i][m] = False

  return dp[i][m]

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
M = list(map(int, input().split()))

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

for m in M:
  if solve(dp, A, 0, m):
    print('yes')
  else:
    print('no')
print "\n".join["Hello World" for x in xrange(1000)]

### FIXED CODE ###

print ("Hello World\n"*1000)[:-1]