Harryxun/stf_run huggingface dataset:
h, w = (list)(map(int, input().split()))
l = [[lin for lin in input()] for _ in range(h)]

gri = [[0 for i in range(w+2)] for _ in range(h+2)]
for i in range(h+2):
    for j in range(w+2):
        if i == 0 or i == h+1 or j == 0 or j == w+1:
            gri[i][j] = '.'
        else:
            gri[i][j] = l[i-1][j-1]

flag = 0
for i in range(1, h+1):
    for j in range(1, w+1):
        if gri[i][j] == '#':
            flag = 1
            if gri[i-1][j] == '.' and gri[i+1][j] == '.' and gri[i][j-1] == '.' and gri[i][j+1] == '.':
                print("No")
                exit(1)

if flag == 0:
    print("No")
else:
    print("Yes")
# print(l)
# print(gri)


### FIXED CODE ###

h, w = (list)(map(int, input().split()))
l = [[lin for lin in input()] for _ in range(h)]

gri = [['.' for i in range(w+2)] for _ in range(h+2)]
for i in range(1, h+1):
    for j in range(1, w+1):
        gri[i][j] = l[i-1][j-1]

flag = 1
for i in range(1, h+1):
    for j in range(1, w+1):
        if gri[i][j] == '#':
            if gri[i-1][j] == '.' and gri[i+1][j] == '.' and gri[i][j-1] == '.' and gri[i][j+1] == '.':
                flag = 0
if flag == 1:
    print("Yes")
else:
    print("No")
a = int(input())
b = int(input())
c = a*b
if(cc%2==0):
    print("Even")
elif(c%2==1):
    print("Odd")

### FIXED CODE ###

a,b = map(int,input().split())
c = a*b
if(c%2==0):
    print("Even")
elif(c%2==1):
    print("Odd")
from math import sqrt
N = int(input())
ans = []
for i in range(1, int(sqrt(N))):
    if i * (N // i) == N:
        ans.append(max(len(str(i)), len(str(N // i))))
        
print(max(min(ans), 1))

### FIXED CODE ###

from math import sqrt
N = int(input())
ans = []
for i in range(1, int(sqrt(N)) + 1):
    if i * (N // i) == N:
        ans.append(max(len(str(i)), len(str(N // i))))
print(min(ans))
N = int(input())
a = list(int(i) for i in input().split())
a.sort(reverse = True)
print(a[0]-a[-1])

### FIXED CODE ###

N = int(input())
if N % 2 == 0:
    print(N)
else:
    print(2*N)
A=[0]*6
for i in range(6):
  A[i]=int(input())
for i in range(5):
  for j in range(5):
    if A[i]-A[j]>A[6]:
      print(':(')
      exit()
print('Yay!')

### FIXED CODE ###

A=[0]*6
for i in range(6):
  A[i]=int(input())
for i in range(5):
  for j in range(5):
    if A[i]-A[j]>A[5]:
      print(':(')
      exit()
print('Yay!')
n,m= map(int, input().split())

print(((n+(n-1))+m(m-1))/2)


### FIXED CODE ###

n,m= map(int, input().split())
 
print(int(((n*(n-1))+m*(m-1))/2))
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
	n = len(numbers)
	#print(numbers)
    #lcm_tmp = (numbers[0] * numbers[1]) // fractions.gcd(numbers[0], numbers[1])
	lcm_tmp = lcm_base(numbers[0],numbers[1])
	for i in range(2,n):
		lcm_tmp = lcm_base(numbers[i],lcm_tmp)
	return lcm_tmp

n,m = map(int,input().split())
t = list(map(int,input().split()))
#print(t)
#lcm = (a * b) // fractions.gcd(a, b)
lcm = lcm_list(t)
x = m // (lcm /2 )
y = m // (lcm)
print(int(x-y))

### FIXED CODE ###

# 100 points
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
k, x = map(int, input().split())
if k*500 >= x:
    # 出力
    print('Yes')
else:
    # 出力
    print('No')# 100 points
import collections
n = int(input())
v = list(map(int, input().split()))
a = []
b = []
for i in range(n // 2):
    a.append(v[(i+1)*2-1])
    b.append(v[(i+1)*2-2])
a = collections.Counter(a)
b = collections.Counter(b)


if a.most_common()[0][0] != b.most_common()[0][0]:
    print(n-a.most_common()[0][1]-b.most_common()[0][1])
elif a.most_common()[1][0] + b.most_common()[0][0] > a.most_common()[0][0] + b.most_common()[1][0]
    print(n-a.most_common()[1][0] - b.most_common()[0][0])
else:
    print(n-a.most_common()[0][0] - b.most_common()[1][0])

### FIXED CODE ###

import collections
n = int(input())
v = list(map(int, input().split()))
a = []
b = []
for i in range(n // 2):
    a.append(v[(i+1)*2-1])
    b.append(v[(i+1)*2-2])
a = collections.Counter(a)
b = collections.Counter(b)


if a.most_common()[0][0] != b.most_common()[0][0]:
    print(n - a.most_common()[0][1] - b.most_common()[0][1])
elif len(a.most_common()) == 1 and len(b.most_common()) == 1:
    print(n//2)
elif a.most_common()[1][1] + b.most_common()[0][1] > a.most_common()[0][1] + b.most_common()[1][1]:
    print(n - a.most_common()[1][1] - b.most_common()[0][1])
else:
    print(n - a.most_common()[0][1] - b.most_common()[1][1])
n = int(raw_input())


c = 2 * (n / 11) if n > 11 else 0
h = {}
for i in range(1, 6+1):
	h[i] = 1
for i in range(7, 12):
	h[i] = 2
if n in h:
	print h[n]
else:
	print h[n % 11] + c


### FIXED CODE ###

n = int(raw_input())


c = 2 * (n / 11)
h = {0:0}
for i in range(1, 6+1):
	h[i] = 1
for i in range(7, 12):
	h[i] = 2
if n in h:
	print h[n]
else:
	print h[n % 11] + c
A,B=map(int.input().split())
if A%3==0 or B%3==0 or (A+B)%3==0:
  print("Possible")
else:
  print("Impossible")

### FIXED CODE ###

A,B=map(int,input().split())
if A%3==0 or B%3==0 or (A+B)%3==0:
  print("Possible")
else:
  print("Impossible")
def isok(arg):
    x = 0
    for i in a:
        if arg - i >= 0 and arg-i <= 10**5:
            x += cs[arg-i]
        else:
            x += n
    if x >= m:
        return True
    else:
        return False

def bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if isok(mid):
            ok = mid
        else:
            ng = mid
    return ok

n,m = map(int,input().split())
a = list(map(int,input().split()))
cs = [0]*(10**5+1)
for i in a:
    cs[i] += 1
for i in range(10**5):
    cs[10**5-i-1] += cs[10**5-i]
h = bisect(10**5*2+1,0)
count = 0
ans = 0
for i in a:
    num = max(0,h-i)
    ans += 2*i*cs[num]
    count += cs[num]
ans -= (count-m)*h
print(ans)


### FIXED CODE ###

def isok(arg):
    x = 0
    for i in a:
        if arg - i >= 0:
            if arg-i <= 10**5:
                x += cs[arg-i]
        else:
            x += n
    if x >= m:
        return True
    else:
        return False

def bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if isok(mid):
            ok = mid
        else:
            ng = mid
    return ok

n,m = map(int,input().split())
a = list(map(int,input().split()))
cs = [0]*(10**5+1)
for i in a:
    cs[i] += 1
for i in range(10**5):
    cs[10**5-i-1] += cs[10**5-i]
h = bisect(10**5*2+1,0)
count = 0
ans = 0
for i in a:
    num = max(0,h-i)
    if num <= 10**5:
        ans += 2*i*cs[num]
        count += cs[num]
ans -= (count-m)*h
print(ans)
import numpy as np

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

e = np.eye(n + 1, dtype=int)
for i in range(n - 1):
    a, b = map(int, input().split())
    e[a][b] = 1

for i in reversed(range(2, n)):
    for j in range(1, i):
        if e[i - j][i] == 1:
            e[i - j][i + 1:] += e[i][i + 1:]
        else:
            continue

point = np.zeros(n, dtype=int)
for i in range(q):
    p, x = map(int, input().split())
    point[p - 1] += x
print(e[1:, 1:])
ans = np.dot(point, e[1:, 1:])
print(*ans)

### FIXED CODE ###

from collections import deque
n, q = map(int, input().split())
tree = [[] for _ in range(n+1)]
cnt = [0] * (n+1)

for _ in range(n-1):
    a, b = map(int, input().split())
    tree[a].append(b)
    tree[b].append(a)

for _ in range(q):
    p, x = map(int, input().split())
    cnt[p] += x

queue = deque([1])
visited = {1}
while queue:
    now = queue.popleft()
    visited.add(now)
    for t in tree[now]:
        if t in visited:
            pass
        else:
            queue.append(t)
            cnt[t] += cnt[now]

print(*cnt[1:])
s = input()
t = input()

A = itertools.combinations(list(range(len(t)+1)),2)
for i in A:
    part = t[i[0]:i[1]]
    print(part)
    if part in s:
        ans = len(part)
        
print(len(t) - ans)

### FIXED CODE ###

s= input()
t = input()

count = len(t)

for i in range(len(s) - len(t) + 1):
    str_ = s[i:i + len(t)]
    temp = 0
    for i in range(len(str_)):
        #print(str_[i])
        if str_[i] != t[i]:
            temp += 1
    count = min(count, temp)    
        
print(count)
n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
cost = [0,2,5,5,4,5,6,3,7,6] # cost[a[i]] = a[i]のコスト
dp = [-1]*(n+1)
dp[0] = 0

for i in range(2,n+1):
    for j in range(0,m):
        if dp[i-cost[a[j]]] == -1:
            continue
        else:
            dp[i] = max(dp[i],dp[i-cost[a[j]]]+1)

ans = list()
read = n
for i in reversed(range(0,n-1)):
    if dp[i]+1 == dp[read]:
        if read-i in [2,3,4,7]:
            ans.append(str(cost.index(read-i)))
        elif read-i == 6:
            if 9 in a:
                ans.append(str(9))
            else:
                ans.append(str(6))
        elif read -i == 5:
            if 5 in a:
                ans.append(str(5))
            elif 3 in a:
                ans.append(str(3))
            else:
                ans.append(str(2))
        read = i
ans.sort()
print("".join(reversed(ans)))

### FIXED CODE ###

n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
cost = [0,2,5,5,4,5,6,3,7,6] 
dp = [-1]*(n+1)
dp[0] = 0

for i in range(2,n+1):
    for j in range(0,m):
        if i-cost[a[j]] <0:
            continue
        if dp[i-cost[a[j]]] == -1:
            continue
        else:
            dp[i] = max(dp[i],dp[i-cost[a[j]]]+1)

ans = list()
read = n
a.sort()
a.reverse()

while read > 0:
    for i in range(0,m):
        if read < cost[a[i]]:
            continue
        if dp[read-cost[a[i]]] == dp[read]-1:
            ans.append(str(a[i]))
            read -= cost[a[i]]
            break
    
print("".join(ans))
s = list(input())
K = int(input())

l =[]

for i in range(len(s)):
    tmp = ''
    for j in range(i, len(s)):
        if j > i + 4: break
        tmp += s[j]
        l.append(tmp)
l.sort()

l2 = list(set(l))

ans = l2[K - 1]

print(ans)


### FIXED CODE ###

a, b, c, d = map(int, input().split())
if (abs(a-b)<=d and abs(b-c)<=d) or abs(a-c)<=d:
    print("Yes")
else:
    print("No")
from heapq import heappush, heappop
from collections import Counter
class HeapSet:
    def __init__(self):
        self.minQue = []
        self.maxQue = []
        self.counter = Counter()

    def insert(self, x):
        heappush(self.minQue, x)
        #heappush(self.maxQue, -x)
        self.counter[x] += 1

    def erase(self, x):
        self.counter[x] -= 1

    def max(self):
        while self.maxQue and self.counter[-self.maxQue[0]] == 0:
            heappop(self.maxQue)
        return -self.maxQue[0] if self.maxQue else None

    def min(self):
        while self.minQue and self.counter[self.minQue[0]] == 0:
            heappop(self.minQue)
        return self.minQue[0] if self.minQue else None

MOD = 998244353
def resolve():
    def dfs(v):
        res = 1
        for to in to_edge[v]:
            res *= dfs(to)
            res %= MOD
        return res +1

    N = int(input())
    AB = [tuple(map(int, input().split())) for _ in range(N)]
    AB.sort()
    st = HeapSet()
    to_edge = [[] for _ in range(N)]
    # treeを作成
    for i in range(N-1, -1, -1):
        x = AB[i][0] # 初期位置
        d = AB[i][1] # 移動距離

        while st.min() and st.min()[0] < x + d:
            to_edge[i].append(st.min()[1])
            st.erase(st.min())
        st.insert((x,i)) # 初期位置、頂点番号

    ans = 1
    for (x, v) in st.minQue:
        ans *= dfs(v)
        ans %= MOD
    print(ans)

if __name__ == "__main__":
    resolve()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from collections import Counter
class HeapSet:
    def __init__(self):
        self.minQue = []
        self.maxQue = []
        self.counter = Counter()

    def insert(self, x):
        heappush(self.minQue, x)
        #heappush(self.maxQue, -x)
        self.counter[x] += 1

    def erase(self, x):
        self.counter[x] -= 1

    def max(self):
        while self.maxQue and self.counter[-self.maxQue[0]] == 0:
            heappop(self.maxQue)
        return -self.maxQue[0] if self.maxQue else None

    def min(self):
        while self.minQue and self.counter[self.minQue[0]] == 0:
            heappop(self.minQue)
        return self.minQue[0] if self.minQue else None

MOD = 998244353
def resolve():
    def dfs(v):
        res = 1
        for to in to_edge[v]:
            res *= dfs(to)
            res %= MOD
        return res +1

    N = int(input())
    AB = [tuple(map(int, input().split())) for _ in range(N)]
    AB.sort()
    st = HeapSet()
    to_edge = [[] for _ in range(N)]
    # treeを作成
    for i in range(N-1, -1, -1):
        x = AB[i][0] # 初期位置
        d = AB[i][1] # 移動距離

        while st.min() and st.min()[0] < x + d:
            to_edge[i].append(st.min()[1])
            st.erase(st.min())
        st.insert((x,i)) # 初期位置、頂点番号

    ans = 1
    for (x, v) in st.minQue:
        ans *= dfs(v)
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    resolve()
a,b,c = sorted(map(input().split()))
 print(a,b,c)

### FIXED CODE ###

a, b, c = sorted(input().split())
print(a, b, c)
n, d = map(int, input().split())
if n//(2*d+1) % 0:
    print(n/(2*d+1))
else:
    print(n//(2*d+1)+1)

### FIXED CODE ###

n, d = map(int, input().split())
if n%(2*d+1) == 0:
    print(n//(2*d+1))
else:
    print(n//(2*d+1)+1)
from itertools import*
print(sum(len(j)//2 for _, j in groupby(open(0).read().split()[1:])))

### FIXED CODE ###

from itertools import*
print(sum(len(list(j))//2 for _, j in groupby(open(0).read().split()[1:])))
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

import numpy as np

n = ni()
grid1 = [lc() for _ in range(n)]

grid1 = np.tile(grid1, (2, 2)).tolist()
grid1trans = list(zip(*grid1))

row = [[""]*n for _ in range(n)]
col = [[""]*n for _ in range(n)]

for r in range(n):
    cur = grid1[r][:n]
    
    for st in range(n):
        row[r][st] = cur
        
        cur = cur[1:]
        cur.append(grid1[r][st])
        
for c in range(n):
    cur = list(grid1trans[c][:n])
    
    for st in range(n):      
        col[c][st] = cur
        
        cur = cur[1:]
        cur.append(grid1trans[c][st])
        
ans = 0

for r in range(n):
    for c in range(n):
        ok = True
        
        for check in range(n):
            if row[(r+check)%n][(c+check)%n] != col[(c+check)%n][(r+check)%n]:
                ok = False
                
        if ok:
            ans += 1
            
print(ans)
            

### FIXED CODE ###

import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
 
n = ni()
grid = []
 
for _ in range(n):
    s = ns()
    s = s+s
    grid.append(s)
    
for i in range(n):
    grid.append(grid[i])
    
vert = []
hrzn = []
 
for i in range(2*n):
    hrzn.append(grid[i])
    
for j in range(2*n):
    temp = ""
    for i in range(2*n):
        temp += grid[i][j:j+1]
        
    vert.append(temp)
    
    
ans = 0
 
for a in range(n):
    for b in range(1):
        
        ok = True
        for i in range(n-1):
 
            if vert[b+i][a+i:a+n] != hrzn[a+i][b+i:b+n]:
                ok = False
                break
                
        if ok:
            ans += 1
            
print(ans*n)
s=int(input())
arr=[s]
tmp=0
for i in range(m):
  if arr[i]%2==0:
    tmp=int(arr[i]/2)
  else:
    tmp=arr[i]*3+1
  if tmp in arr:
    print(i+1)
    break
  arr.append(tmp)
  

### FIXED CODE ###

s=int(input())
arr=[s]
tmp=0
for i in range(10**6+1):
  if arr[i]%2==0:
    tmp=int(arr[i]/2)
  else:
    tmp=arr[i]*3+1
  if tmp in arr:
    print(i+2)
    break
  arr.append(tmp)
N = int(input())

p = []

for i in raneg(N):
    p.append(int(input()))


new_p = sorted(p, reverse=True)

p_max = (new_p[0]/2)

NEW_p = (new_p[1:len(new_p)])

NEWP_SUM = sum(NEW_p)

print(int((p_max) + (NEWP_SUM)))

### FIXED CODE ###

N = int(input())
p = []
for _ in range(N):
    p.append(int(input()))
p = sorted(p)
p[-1] = p[-1]//2
print(sum(p))
n k = map(int,input().split())
print(n-k+1)

### FIXED CODE ###

n, k = map(int,input().split())
print(n-k+1)
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())

if v<=w:
    print("NO")
else:
    if abs(b-a)<=(v-w):
    if abs(b-a)%(v-w)==0 and abs(b-a)//(v-w)<=t:
        print("YES")
    else:
        print("NO")

### FIXED CODE ###

a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())

if v<=w:
    print("NO")
else:
    if abs(b-a)<=t*(v-w):
        print("YES")
    else:
        print("NO")
a,b,c=map(int,input().split())
d=list(map(int, input().split())
d.append(c)
d.sort()
print(min(d.index(c), len(d)-d.index(c)-1))

### FIXED CODE ###

n,m,x=map(int,input().split())
s=sum(int(i)<x for i in input().split())
print(min(s,m-s))
N = int(input())
list = list(int(input()))
count=0
while all(i%2 == 0 for i in list):
    count+=1
    list=[j/2 for j in list]
print(count)

### FIXED CODE ###

N = int(input())
list = list(map(int, input().split()))
count=0
while all(i%2 == 0 for i in list):
    count+=1
    list=[j/2 for j in list]
print(count)
k,x = map(int,input().spleit())

if x <= k*500:
    print('Yes')

else:
    print('No')


### FIXED CODE ###

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

if  500*k >= x:
  print('Yes')
else:
  print('No')
from collections import defaultdict

types = ['AC', 'WA', 'TLE', 'RE']
num = int(input())
categories = defaultdict(int)

for i in range(num):
    categories[input()] += 1

for i in types:
    print("{} x {}".format(i, categories[i]))

### FIXED CODE ###

a = int(input())

if a % 1000 == 0:
  out = 0
else:
  out = 1000 - a % 1000

print(out)
n = int(raw_input())
m = len(str(n))
for a in range(2, n ** 0.5 + 1):
	if n % a == 0:
		m = min(m, max(len(str(a)), len(str(n/a))))
print m

### FIXED CODE ###

n = int(raw_input())
m = len(str(n))
for a in range(2, int(n ** 0.5) + 1):
	if n % a == 0:
		m = min(m, max(len(str(a)), len(str(n/a))))
print m
import math
a, b, c, d = map(int, input().split())
e = (c*d)/math.gcd(c,d)
bb = b-(b//c + b//d- b//e)
aa = a-1-((a-1)//c+(a-1)//d-(a-1)//e)
z = bb-aa
print(z)

### FIXED CODE ###

S = input()
A = sorted(S)
if A[0] == A[1] == A[2]:
    print('No')
elif A[0] == A[1] and A[2] == A[3]:
    print('Yes')
else:
    print('No')
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

D = i()
c = l()
ans = [0]*D
for i in range(D):
    s = l()
    ans[i] = s.index(max(s))+1
for i in range(26):
    d = D//c[i]
    for j in range(i,D,d-1):
        print(j)
        ans[j] = i+1
for i in ans:
    print(i)

### FIXED CODE ###

import random
for i in range(365):
  print(random.randint(1,26))
a, b = map(int, input().split())
print(int((a+b)*o.5+0.9))

### FIXED CODE ###

a, b = map(int, input().split())
 
c = (a+b) / 2
 
print(int(c+0.9))
a = list(map(int, raw_input().split()))

a.sort()

if a == [5,5,7]:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

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

a.sort()

if a == [5,5,7]:
    print("YES")
else:
    print("NO")
import itertools
import numpy as np
n,m,q=map(int, input().split())  
a=[list(map(int, input().split())) for i in range(m)]
b=[list(map(int, input().split())) for i in range(q)]

x=[[0]*(501) for i in range(501)]

for i in range(m):
    x[a[i][0]][a[i][1]]+=1



for i in range(501):
    x[i] = list(itertools.accumulate(x[i]))
  
x=np.array(x)
for i in range(501):
    x[:,i] = list(itertools.accumulate(x[:,i]))



for i in range(q):
    v1=b[i][0]
    v2=b[i][1]
    
    a1=x[v2,v2]
    a2=x[v2,v1-1]
    a3=x[v1-1,v2]
    a4=x[v1-1,v1-1]
    print(a1-a2-a3+a4)


 







### FIXED CODE ###

import itertools
import numpy as np
n,m,q=map(int, input().split())  
a=[list(map(int, input().split())) for i in range(m)]
b=[list(map(int, input().split())) for i in range(q)]

x=[[0]*(501) for i in range(501)]

for i in range(m):
    x[a[i][0]][a[i][1]]+=1



for i in range(501):
    x[i] = list(itertools.accumulate(x[i]))
  
x=np.array(x)
for i in range(501):
    x[:,i] = list(itertools.accumulate(x[:,i]))



for i in range(q):
    v1=b[i][0]
    v2=b[i][1]
    
    a1=x[v2,v2]
    a2=x[v2,v1-1]
    a3=x[v1-1,v2]
    a4=x[v1-1,v1-1]
    print(a1-a2-a3+a4)
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *


def solve(H: int, W: int, A: "List[str]"):
    queue = deque()

    rem = H * W
    for i in range(H):
        for j in range(W):
            if A[i][j] == '#':
                queue.append((i, j, 0))
    
    ret = 0
    visited = [[False] * W for _ in range(H)]
    while 0 < len(queue):
        i, j, n = queue.popleft()
        if visited[i][j]:
            continue
        visited[i][j] = True
        ret = max(ret, n)

        rem -= 1
        #if rem == 0:
        #    break

        for dx, dy in zip([0, 1, 0, -1], [1, 0, -1, 0]):
            nx = j + dx
            ny = i + dy
            if (0 <= nx < W) and (0 <= ny < H):
                queue.append((ny, nx, n + 1))
        #if 0 < j:
        #    queue.append((i, j - 1, n + 1))
        #if j < W - 1:
        #    queue.append((i, j + 1, n + 1))
        #if 0 < i:
        #    queue.append((i - 1, j, n + 1))
        #if i < H - 1:
        #    queue.append((i + 1, j, n + 1))
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    A = [ next(tokens) for _ in range(W) ]  # type: "List[str]"
    result = solve(H, W, A)
    print(result)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *


def solve(H: int, W: int, A: "List[str]"):
    queue = deque()

    rem = H * W
    visited = [True] * ((W+2) * (H+2))
    for i in range(W+2):
        visited[i] = False
        visited[(W + 2) * (H + 1) + i] = False
    for i in range(H+2):
        visited[(W + 2) * i] = False
        visited[(W + 2) * i + (W + 1)] = False

    for i in range(H):
        l = A[i]
        for j in range(W):
            if l[j] == '#':
                queue.append((i+1, j+1, 0))
                k = i * (W + 2) + j
                visited[k] = False

    ret = 0
    while queue:
        i, j, n = queue.popleft()
        k = i * (W + 2) + j
        if not visited[k] and 0 < n:
            continue
        visited[k] = False
        ret = n
        rem -= 1

        if rem == 0:
            break

        if visited[k - 1]:
            queue.append((i, j - 1, n + 1))
        if visited[k + 1]:
            queue.append((i, j + 1, n + 1))

        if visited[k - (W + 2)]:
            queue.append((i - 1, j, n + 1))
        if visited[k + (W + 2)]:
            queue.append((i + 1, j, n + 1))
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    A = [ next(tokens) for _ in range(H) ]  # type: "List[str]"
    result = solve(H, W, A)
    print(result)

if __name__ == '__main__':
    main()