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

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

#初期値が0の辞書
from collections import defaultdict
lrd = defaultdict(lambda: []) 

yx=[[0]*n for _ in range(n)]

for _ in range(m):
    l,r,d=map(int,input().split())
    lrd[l-1].append(r-1)
    lrd[r-1].append(l-1)
    yx[l-1][r-1]=d



def BFD(x):
    global checked,answer
    checked[x]=1
    #print("x>>>",x)
    for item in lrd[x]:
        #print(lrd,item,x)
        ll=min(item,x)
        rr=max(item,x)
        if answer[item]==-1:
            if item<=x:
                answer[item]=answer[x]-yx[item][x]
            else:
                answer[item]=answer[x]+yx[x][item]
        else:
            if answer[rr]!=answer[ll]+yx[ll][rr]:
                print("No")
                exit()
        if checked[item]==0:
            BFD(item)

checked=[0]*n

for i in range(n):
    if checked[i]==0:
        answer = defaultdict(lambda: -1) 
        answer[i]=1
        BFD(i)

print("Yes")


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)
input=sys.stdin.readline

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

lrd=[[] for _ in range(n)]

for _ in range(m):
    l,r,d=map(int,input().split())
    lrd[l-1].append((r-1,-d))
    lrd[r-1].append((l-1,+d))

def BFD(x):
    global checked,answer,lrd
    checked[x]=1
    #print("x>>>",x,lrd[x])
    for llrrdd in lrd[x]:
        #print(llrrdd,x)
        item=llrrdd[0]
        if answer[item]=="first":
            answer[item]=answer[x]-llrrdd[1]
        else:
            if answer[item]!=answer[x]-llrrdd[1]:
                print("No")
                exit()
        if checked[item]==0:
            BFD(item)

checked=[0]*n
answer = ["first"]*n

for i in range(n):
    if checked[i]==0:
        answer[i]=1
        BFD(i)

print("Yes")
### BUGGY CODE ###

a,b,k = map(int, input().split())
target = [i for i in range(a,b+1)]
print(*sorted(set(target[:k]+target[len(target)-k:])), sep='\n')

### FIXED CODE ###

a, b, k = map(int, input().split())
list_1 = [i for i in range(a, a+k) if i<=b]
list_2 = [i for i in range(b-k+1, b+1) if a<=i]
list_1.extend(list_2)
print(*sorted(set(list_1)), sep = '\n')
### BUGGY CODE ###

def main():
    from sys import stdin

    H, W = map(int, input().split())
    g = []
    q = []
    cnt = 0
    for h in range(H):
        A = stdin.readline()
        row = []
        for w in range(W):
            row.append(A[w])
            if A[w] == '#':
                cnt += 1
                q.append((h, w))
        g.append(row)
    ans = 0
    dh = [1, 0, 0, -1]
    dw = [0, -1, 1, 0]
    while cnt < H * W:
        ans += 1
        nextq = []
        while q:
            h, w = q.pop()
            for i in range(4):
                nh = h + dh[i]
                nw = w + dw[i]
                if 0 <= nh < H and 0 <= nw < W and g[nh][nw] == '.':
                    g[nh][nw] = '#'
                    nextq.append((nh, nw))
                    cnt += 1
        q = nextq
    print(ans)
main()


### FIXED CODE ###

def main():
    H, W = map(int, input().split())
    g = []
    q = []
    cnt = 0
    for h in range(H):
        A = str(input())
        row = []
        for w in range(W):
            row.append(A[w])
            if A[w] == '#':
                cnt += 1
                q.append([h, w])
        g.append(row)
    ans = 0
    dh = [1, 0, 0, -1]
    dw = [0, -1, 1, 0]
    while cnt < H * W:
        ans += 1
        nextq = []
        while q:
            h, w = q.pop()
            for i in range(4):
                nh = h + dh[i]
                nw = w + dw[i]
                if 0 <= nh < H and 0 <= nw < W and g[nh][nw] == '.':
                    g[nh][nw] = '#'
                    nextq.append([nh, nw])
                    cnt += 1
        q = nextq
    print(ans)
main()
### BUGGY CODE ###

def getval():
    s = input()
    t = input()
    return s,t

def main(s,t):
    dp = [["" for i in range(len(t)+1)]]
    for i in range(len(s)):
        temp = [""]
        for j in range(len(t)):
            if s[i]==t[j]:
                temp.append("".join([dp[i][j],s[i]]))
            else:
                if len(dp[i][j+1])>len(temp[-1]):
                    temp.append(dp[i][j+1])
                else:
                    temp.append(temp[-1])
        dp.append(temp)
    print(dp[len(s)][len(t)])
                    
if __name__=="__main__":
    s,t = getval()
    main(s,t)

### FIXED CODE ###

from copy import copy

def getval():
    s = input()
    t = input()
    return s,t

def main(s,t):
    dp = ["" for i in range(len(t)+1)]
    for i in range(len(s)):
        temp = [""]
        for j in range(len(t)):
            prev = dp[j+1]
            last = temp[-1]
            if len(prev)>len(last):
                temp.append(prev)
            elif len(prev)<len(last):
                temp.append(last)
            elif s[i]==t[j]:
                temp.append("".join([dp[j],s[i]]))
            else:
                temp.append(prev)
        dp = copy(temp)
        
    print(dp[len(t)])
                    
if __name__=="__main__":
    s,t = getval()
    main(s,t)
### BUGGY CODE ###

N = int(input())
P = list(map(int, input().split(' ')))
cnt = 0
for i in range(N):
    if P[i] <= min(P[0:i+1]):
        cnt += 1
print(cnt)


### FIXED CODE ###

N = int(input())
P = list(map(int, input().split(' ')))
cnt = 1
j = P[0]
for i in range(1, N):
    j = min(j, P[i])
    if P[i] <= j:
        cnt += 1
print(cnt)
### BUGGY CODE ###

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

from collections import deque

neig = [(1, 0), (-1, 0), (0, 1), (0, -1)]

H, W = map(int, input().split())

F = []
nW = 0
for _ in range(H):
    F.append(list(input()))
    nW += sum([1 for s in F[-1] if s == '.'])

ans = -1
q = deque()
q.append((0, 0, 1))
while q:
    y, x, count = q.popleft()
    F[y][x] = 'V' # Visited
    if y == H - 1 and x == W - 1:
        ans = nW - count
    for n in neig:
        ny, nx = y + n[0], x + n[1]
        if 0 <= ny < H and 0 <= nx < W:
            if F[ny][nx] == '.':
                q.append((ny, nx, count + 1))

print(ans)


### FIXED CODE ###

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

from collections import deque

neig = [(1, 0), (-1, 0), (0, 1), (0, -1)]

H, W = map(int, input().split())

F = []
nW = 0
for _ in range(H):
    F.append(list(input()))
    nW += sum([1 for s in F[-1] if s == '.'])

ans = -1
q = deque()
q.append((0, 0, 1))
F[0][0] = 'V' # Visited

while q:
    y, x, count = q.popleft()
    if y == H - 1 and x == W - 1:
        ans = nW - count
        break
    for n in neig:
        ny, nx = y + n[0], x + n[1]
        if 0 <= ny < H and 0 <= nx < W:
            if F[ny][nx] == '.':
                q.append((ny, nx, count + 1))
                F[ny][nx] = 'V' # Visited

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

#!/usr/bin/env python3
import sys
import heapq

def solve(N: int, M: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    heapq.heapify(A)
    for m in range(M):
        for _ in range(B[m]):
            heapq.heappushpop(A, C[m])
    print(sum(A))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    C = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        B[i] = int(next(tokens))
        C[i] = int(next(tokens))
    solve(N, M, A, B, C)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

from itertools import chain


class BinarySearcher(object):
    def __init__(self, condition, initial_values):
        self.condition = condition
        self.initial_values = initial_values
        # all True
        if self.condition(initial_values[0]):
            self.first_solution = 0
        # all False
        elif not self.condition(initial_values[1]):
            self.first_solution = None
        else:
            self.first_solution = self.search_first_solution(
                *self.initial_values)

    def search_first_solution(self, lower, upper):
        if upper - lower <= 1:
            return condition(n)
        n = (lower + upper) // 2
        if self.condition(n):
            if not self.condition(n - 1):
                return n
            return self.search_first_solution(lower, n)
        else:
            return self.search_first_solution(n, upper)


def solve(N: int, M: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    A = sorted(A)
    bc = sorted(zip(B, C), key=lambda x: x[1], reverse=True)
    D = []
    for b, c in bc:
        D.extend([c] * b)
        if len(D) >= N:
            break
    length = min(len(A), len(D))
    r = BinarySearcher(lambda x: A[x] > D[x], (0, length - 1)).first_solution
    if r is None:
        r = length
    print(sum(A[r:]) + sum(D[:r]))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    C = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        B[i] = int(next(tokens))
        C[i] = int(next(tokens))
    solve(N, M, A, B, C)


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

a, b, c, k = map(int,input().split())
for _ in range(k):
  a, b, c = b+c, c+a, a+b
print("Unfair" if a-b>1e16 else a-b)

### FIXED CODE ###

a, b, c, k = map(int, input().split())
print((a-b)*(-1)**k)
### BUGGY CODE ###

N, A, B = map(int, input().split())
h = [int(input()) for _ in range(N)]
h.sort()
h.reverse()

ans = h
cnt = 0

while ans:
    ans[0] -= A
    for i in range(1, len(ans)):
        ans[i] -= B
        
    ans = [x for x in ans if x > 0]
    ans.sort()
    ans.reverse()

    cnt += 1

print(cnt)


### FIXED CODE ###

from math import ceil

N, A, B = map(int, input().split())
h = [int(input()) for _ in range(N)]

def enough(t):
    cnt = 0
    
    for hp in h:
        cnt += ceil(max(0, (hp - B * t)/(A-B)))
        
    if cnt <= t:
        return True
    else:
        return False

high = ceil(max(h) / B)
low = 0

while high - low > 0:
    mid = (high + low) // 2
    if enough(mid):
        high = mid
    else:
        low = mid + 1

print(low)
### BUGGY CODE ###

from fractions import gcd
from functools import reduce

_ = input()
A = list(map(int, input().split()))
#print("A", A)

result = 1
for i, a in enumerate(A):
    #print("ignore", a)
    A.pop(i)
    #print("current A", A)

    result = max(result, reduce(gcd, A))
    
    A.insert(i, a)
    #print("org A", A)
    #print("---")

print(result)


### FIXED CODE ###

from fractions import gcd
from sys import exit

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

l_gcd_list = [0]
r_gcd_list = [0]
for i in range(N):
    l_gcd_list.append(gcd(l_gcd_list[i], A[i]))
    r_gcd_list.append(gcd(r_gcd_list[i], A[-(i+1)]))
r_gcd_list = r_gcd_list[::-1]
# print(l_gcd_list)
# print(r_gcd_list)

results = []
for i in range(N):
    results.append(gcd(l_gcd_list[i], r_gcd_list[i+1]))

print(max(results))
### BUGGY CODE ###

from copy import deepcopy
n = str(input().rstrip())

def solve1(n):
    ans = 0

    a = list(map(int, list(n)))
    a = a[::-1]
    a.append(0)
    for i in range(len(a) - 1):
        c = a[i]
        if c < 5:
            ans += c
        else:
            if c == 5 and a[i+1] < 5:
                ans += 5
            else:
                a[i+1] += 1
                ans += 10 - c
    ans += n_list[-1]

    print(ans)

def solve2(n):
    INF = 10**9
    n = n[::-1]
    n += '0'
    n_len = len(n)
    dp = [INF for _ in range(2)]
    dp[0] = 0

    for i in range(n_len):
        pre_dp = deepcopy(dp)
        dp = [INF, INF]
        for j in range(2):
            x = int(n[i])
            x += j
            if x < 10:
                dp[0] = min(dp[0], pre_dp[j]+x)
            if x > 0:
                dp[1] = min(dp[1], pre_dp[j]+(10-x))

    print(dp[0])
solve2(n)

### FIXED CODE ###

n = str(input().rstrip())

ans = 0

a = list(map(int, list(n)))
a = a[::-1]
a.append(0)
for i in range(len(a) - 1):
    c = a[i]
    if c < 5:
        ans += c
    else:
        if c == 5 and a[i+1] < 5:
            ans += 5
        else:
            a[i+1] += 1
            ans += 10 - c
ans += a[-1]

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

N=int(input())
L=list(map(int,input().split()))
[print(sorted(L[:i]+L[i+1:])[N//2-1]) for i in range(N)]

### FIXED CODE ###

N=int(input())
L=list(map(int,input().split()))
LL=sorted(L)
M1=LL[N//2-1]
M2=LL[N//2]
for i in L:
  if i>=M2:
    print(M1)
  else:
    print(M2)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
def main():
  n,m,s=map(int,input().split())
  uvab=[list(map(int,input().split())) for _ in range(m)]
  cd=[list(map(int,input().split())) for _ in range(n)]
  g=[[]for _ in range(n)]
  for u,v,a,b in uvab:
    g[u-1].append([v-1,a,b])
    g[v-1].append([u-1,a,b])
  import heapq
  inf=pow(10,21)
  dp=[[inf]*(100*51)for _ in range(n)]
  kakutei=[[0]*(100*51)for _ in range(n)]
  dp[0][min(s,100*51-1)]=0
  todo=[[0,0,min(s,100*51-1)]] # [dp[v][i],v,i]
  heapq.heapify(todo)
  flgs=[0]*n
  flg=0
  ans=[inf]*n
  while flg<n:
    _,v,i=heapq.heappop(todo)
    if kakutei[v][i]==1:
      continue
    kakutei[v][i]=1
    if flgs[v]==0:
      flg+=1
      flgs[v]=1
    c,d=cd[v]
    ans[v]=min(ans[v],_)
    # 両替
    j=min(100*51-1,i+c)
    if kakutei[v][j]==0:
      dp[v][j]=min(dp[v][j],dp[v][i]+d)
      heapq.heappush(todo,[dp[v][j],v,j])
    # 鉄道
    l=g[v]
    for u,a,b in l:
      if i-a>=0 and kakutei[u][i-a]==0:
        dp[u][i-a]=min(dp[u][i-a],dp[v][i]+b)
        heapq.heappush(todo,[dp[u][i-a],u,i-a])
  print(*ans[1:],sep='\n')
if __name__=='__main__':
  main()


### FIXED CODE ###

import sys
input = sys.stdin.readline
def main():
  n,m,s=map(int,input().split())
  uvab=[list(map(int,input().split())) for _ in range(m)]
  cd=[list(map(int,input().split())) for _ in range(n)]
  g=[[]for _ in range(n)]
  for u,v,a,b in uvab:
    g[u-1].append((v-1,a,b))
    g[v-1].append((u-1,a,b))
  import heapq
  inf=pow(10,21)
  max_s=50*50
  dp=[[inf]*(max_s+1)for _ in range(n)]
  kakutei=[[0]*(max_s+1)for _ in range(n)]
  dp[0][min(s,max_s)]=0
  todo=[[0,0,min(s,max_s)]] # [dp[v][i],v,i]
  heapq.heapify(todo)
  flgs=[0]*n
  flg=0
  ans=[inf]*n
  while flg<n:
    _,v,i=heapq.heappop(todo)
    if kakutei[v][i]==1:
      continue
    kakutei[v][i]=1
    if flgs[v]==0:
      flg+=1
      flgs[v]=1
    c,d=cd[v]
    ans[v]=min(ans[v],_)
    # 両替
    j=min(max_s,i+c)
    if kakutei[v][j]==0:
      dp[v][j]=min(dp[v][j],dp[v][i]+d)
      heapq.heappush(todo,[dp[v][j],v,j])
    # 鉄道
    l=g[v]
    for u,a,b in l:
      if i-a>=0 and kakutei[u][i-a]==0:
        dp[u][i-a]=min(dp[u][i-a],dp[v][i]+b)
        heapq.heappush(todo,[dp[u][i-a],u,i-a])
  print(*ans[1:],sep='\n')
if __name__=='__main__':
  main()
### BUGGY CODE ###

n,v=[int(k) for k in input().split()]
li=[]
for i in range(n):
  li.append([int(k) for k in input().split()])
  
dp=[[0 for i in range(v+1)] for j in range(n+1)]
for a in range(1,n+1):
  for b in range(1,v+1):
    if(li[a-1][0]<=b):
      dp[a][b]=max(li[a-1][1]+dp[a-1][b-li[a-1][0]],dp[a-1][b])
    else:
      dp[a][b]=dp[a-1][b]
print(dp[n][v])      
      
  

### FIXED CODE ###

n,v=[int(k) for k in input().split()]
li=[]
for i in range(n):
  li.append([int(k) for k in input().split()])
  
dp=[[0 for i in range(v+1)] for j in range(n+1)]
for a in range(1,n+1):
  for b in range(1,v+1):
    if(li[a-1][0]<=b):
      dp[a][b]=max(li[a-1][1]+dp[a-1][b-li[a-1][0]],dp[a-1][b])
    else:
      dp[a][b]=dp[a-1][b]
print(dp[n][v])
### BUGGY CODE ###

import fractions
import itertools
from functools import reduce
n = int(input())
a = list(map(int,input().split()))

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

c = list(itertools.combinations(a,n-1))
ans = 1
for i in c:
  ans = max(ans,gcd_list(i))
print(ans)

### FIXED CODE ###

n=int(input())
a=sorted(list(map(int,input().split())))
i=a[1]
while i > 0:
  flg=0
  for j in a:
    if j%i!=0:
      flg+=1
      if flg>1:
        break
  if flg<=1:
    print(i)
    break
  else:
    i-=1
### BUGGY CODE ###

H,W,M = map(int,input().split())
P = [0]*(H+1)
Q = [0]*(W+1)
A = [[0 for j in range(W+1)] for i in range(H+1)]
for k in range(M):
  a,b = map(int,input().split())
  P[a] += 1
  Q[b] += 1
  A[a][b] = 1
#print(P,Q,A,Pmax,Qmax,ans)
Pindex = [i for i, v in enumerate(P) if v == max(P)]
Qindex = [i for i, v in enumerate(Q) if v == max(Q)]
Pmax = P[Pindex[0]]
Qmax = Q[Qindex[0]]
ans = Pmax+Qmax-1
key = 0
for x in Pindex:
  for y in Qindex:
    if A[x][y] == 0:
      ans += 1
      key = 1
      break
  if key == 1:
    break
print(ans)

### FIXED CODE ###

H,W,M = map(int,input().split())
P = [0]*(H+1)
Q = [0]*(W+1)
A = set()
for k in range(M):
    a,b = map(int,input().split())
    P[a] += 1
    Q[b] += 1
    A.add((a,b))
Pmax = max(P)
Qmax = max(Q)
Pindex = []
Qindex = []
for i in range(H+1):
    if P[i] == Pmax:
        Pindex.append(i)
for i in range(W+1):
    if Q[i] == Qmax:
        Qindex.append(i)
ans = Pmax+Qmax-1
key = 0
for x in Pindex:
  for y in Qindex:
    if (x,y) not in A:
      ans += 1
      key = 1
      break
  if key == 1:
    break
print(ans)
### BUGGY CODE ###

K,S=map(int,input().split())
count=0
for X in range(K+1):
    for Y in range(K+1):
        for Z in range(K+1):
            if X+Y+Z==S:
                count+=1
                
print(count)

### FIXED CODE ###

K,S=map(int,input().split())
count=0
for X in range(K+1):
    for Y in range(K+1):
        if 0<=S-X-Y<=K:
            count+=1
                
print(count)
### BUGGY CODE ###

import heapq as hq
from collections import defaultdict
N, Q = map(int, input().split())
STX = [list(map(int, input().split())) for i in range(N)]
Dlist = [int(input()) for i in range(Q)]
event = []
for s,t,x in STX:
    event.append([s - x, t-x, x])
event.sort(key=lambda x:x[0])
h = []
tdic = defaultdict(int)
ind = 0
for Di in Dlist:
    while ind<N and event[ind][0] <= Di:
        #Diまでに始まった工事を追加
        hq.heappush(h, event[ind][2])
        tdic[event[ind][2]] = event[ind][1]
        ind += 1
    while h and Di >= tdic[h[0]]:
        #Diまでに終わった工事を削除
        hq.heappop(h)
    if h:
        print(h[0])
    else:
        print(-1)

### FIXED CODE ###

import heapq as hq
from collections import defaultdict
N, Q = map(int, input().split())
event = []
for i in range(N):
    si, ti, xi = map(int, input().split())
    event.append([si - xi, ti - xi, xi])
#STX = [list(map(int, input().split())) for i in range(N)]
Dlist = [int(input()) for i in range(Q)]
#for s,t,x in STX:
#    event.append([s - x, t-x, x])
event.sort(key=lambda x:x[0])
h = []
tdic = defaultdict(int)
ind = 0
for Di in Dlist:
    while ind<N and event[ind][0] <= Di:
        #Diまでに始まった工事を追加
        hq.heappush(h, event[ind][2])
        tdic[event[ind][2]] = event[ind][1]
        ind += 1
    while h and Di >= tdic[h[0]]:
        #Diまでに終わった工事を削除
        hq.heappop(h)
    if h:
        print(h[0])
    else:
        print(-1)
### BUGGY CODE ###

import copy
import sys

sys.setrecursionlimit(10**8)

N, Q = map(int, input().split())
graph = [[] for i in range(N)]

def dfs(v, d, p_list=[0]):
    seen[v] = True
    depth[v] = d
    parents_list[v] = copy.copy(p_list)
    for i in graph[v]:
        if seen[i] == True:
            continue
        p_list.append(i)
        dfs(i, d+1, p_list)
        p_list.pop()

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

seen = [False for i in range(N)]
depth = [0 for i in range(N)]
parents_list = [[] for i in range(N)]
dfs(0, 0)

ans = [0 for i in range(N)]

for i in range(Q):
    p, x = map(int, input().split())
    p -= 1

    for j, parent in enumerate(parents_list):
        if p in parent:
            ans[j] += x

print(*ans)


### FIXED CODE ###

N, Q = map(int, input().split())
graph = [[] for i in range(N)]

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

ans = [0 for i in range(N)]

for i in range(Q):
    p, x = map(int, input().split())
    p -= 1

    ans[p] += x

seen = [False for i in range(N)]

stack = [0]

# dfs
while stack != []:
    v = stack.pop()
    seen[v] = True

    for i in graph[v]:
        if seen[i] == True:
            continue
        ans[i] += ans[v]
        stack.append(i)

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

def calc_minas(n):
    return n - 1

a = list(map(int,input().split()))
n = a[0]
k = a[1]
q = a[2]
#print(n,k,q)
n_list = [k]*n
#print(n_list[0]+100)
#print(n_list)
for i in range(q):
  #print('Q',i)
  seikaisha = int(input())
  #print('seikaishaha',seikaisha)
  n_list = list(map(calc_minas,n_list))
  n_list[seikaisha-1] += 1
  #print(n_list)
for k in range(n):
  if n_list[k] > 0:
    print('Yes')
  else:
    print('No')

### FIXED CODE ###

a = list(map(int,input().split()))
n = a[0]
k = a[1]
q = a[2]
n_list = [0]*n
for i in range(q):
  seikaisha = int(input())
  n_list[seikaisha-1] += 1
  #print(n_list)
for j in range(n):
  if n_list[j]+k-q > 0:
    print('Yes')
  else:
    print('No')
### BUGGY CODE ###

# ContestName
# URL
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def check(i, j, q, count, H, W, A):
    if i < 0 or i >= H:
        return count
    if j < 0 or j >= W:
        return count
    if A[i][j] == '#':
        return count
    A[i][j] = '#'
    count += 1
    q.append((i, j))
    return count

def main():
    H, W = i2nn()
    A = ii2ss(H)
    A = [list(s) for s in A]
    B = A
    HW = H * W
    q = []
    count = 0
    rec = 0
    for i in range(H):
        for j in range(W):
            if A[i][j] == '#':
                q.append((i, j))
                count += 1
    while True:
        if count >= HW or len(q) == 0:
            print(rec)
            return
        rec += 1
        q2 = []
        for i, j in q:
            count = check(i-1, j, q2, count, H, W, B)
            count = check(i+1, j, q2, count, H, W, B)
            count = check(i, j-1, q2, count, H, W, B)
            count = check(i, j+1, q2, count, H, W, B)
        q = q2

main()


### FIXED CODE ###

# AtCoder Grand Contest 033
# https://atcoder.jp/contests/agc033
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

import datetime

def main():
    H, W = i2nn()
    HW = H * W
    A = ii2ss(H)
    A = [[0 if s == '#' else HW for s in line] for line in A]
    for i in range(H):
        for j in range(1, W):
            if A[i][j-1]+1 < A[i][j]:
                A[i][j] = A[i][j-1]+1
        for j in range(W-2, -1, -1):
            if A[i][j+1]+1 < A[i][j]:
                A[i][j] = A[i][j+1]+1
    for j in range(W):
        for i in range(1, H):
            if A[i-1][j]+1 < A[i][j]:
                A[i][j] = A[i-1][j]+1
        for i in range(H-2, -1, -1):
            if A[i+1][j]+1 < A[i][j]:
                A[i][j] = A[i+1][j]+1
    ans = 0
    for i in range(H):
        for j in range(W):
            if A[i][j] > ans:
                ans = A[i][j]
    print(ans)

main()