Harryxun/stf_run huggingface dataset:
N, K = list(map(int, input().split()))
links = [list(map(int, input().split())) for _ in range(N-1)]

if N == 1:
    print(K)
else:
    from scipy import special
    mod = 1000000007
    d = {}
    for a, b in links:
        if a in d:
            d[a].add(b)
        else:
            d[a] = {b}
        if b in d:
            d[b].add(a)
        else:
            d[b] = {a}
    root = {1}
    ans = K
    while True:
        a = K - 2
        if 1 in root:
            a = K - 1
        children = set()
        for i in root:
            for j in d[i]:
                d[j].remove(i)
            b = len(d[i])
            if a < b:
                print(0)
                break
            if b == 0:
                continue
            ans *= special.perm(a, b, exact=True)
            children |= d[i]
        else:
            if len(children) == 0:
                print(ans % mod)
                break
            root = children
            continue
        break

### FIXED CODE ###

N, K = list(map(int, input().split()))
l = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    l[a].append(b)
    l[b].append(a)

deg1 = [0] * (N + 1)
deg2 = [0] * (N + 1)
history = [True] * (N + 1)
stack = [1]
ans = 1

while stack:
    node = stack.pop()
    ans *= K - deg1[node] - deg2[node]
    ans %= 1000000007
    history[node] = False
    for child in l[node]:
        if history[child]:
            deg1[child] += 1
            deg2[child] += deg1[node]
            deg1[node] += 1
            stack.append(child)
            
print(ans)
S = input()
is_easy = False
for i in range(len(S)):
  if i % 2 == 0:
   	if S[i] == "R":
      print("No")
      is_easy = True
      break
  else:
   	if S[i] == "L":
      print("No")
      is_easy = True
      break
      
if not is_diff:
  print("Yes")

### FIXED CODE ###

S = input()
s1 = S[1::2]
s2 = S[::2]


if "L" in s2 or "R" in s1:
    print("No")
else:
    print("Yes")
from math import gcd

def main():
    N = int(input())
    mod = 10**9 + 7
    AB = {}
    pos = set()
    for _ in range(N):
        a, b = map(int, input().split())
        g = gcd(a, b)
        a, b = a // g, b // g
        if a * b < 0 and a > 0:
            a, b = -a, -b
        if a * b > 0 and a < 0:
            a, b = -a, -b
        if a * b == 0:
            a, b = abs(a), abs(b)
        if a * b > 0:
            pos.add((a, b))
        AB[(a, b)] = AB.get((a, b), 0) + 1
    t = N - AB.get((0, 0), 0)
    r = 1
    for a, b in pos:
        p = AB[(a, b)]
        n = AB.get((-b, a), 0)
        r *= (pow(2, p, mod) - 1) + (pow(2, n, mod) - 1) + 1
        r %= mod
        t -= (p + n)
    p = AB.get((0, 1), 0)
    n = AB.get((1, 0), 0)
    r *= (pow(2, p, mod) - 1) + (pow(2, n, mod) - 1) + 1
    t -= (p + n)
    r *= pow(2, t, mod)
    r -= 1

    if (0, 0) in AB:
        r += AB[(0, 0)]

    return r % mod

print(main())


### FIXED CODE ###

from math import gcd

def main():
    N = int(input())
    mod = 10**9 + 7
    AB = {}
    pos = set()
    for _ in range(N):
        a, b = map(int, input().split())
        g = gcd(a, b)
        if g == 0:
            AB[(0, 0)] = AB.get((0, 0), 0) + 1
            continue
        a, b = a // g, b // g
        if a * b < 0 and a > 0:
            a, b = -a, -b
        if a * b > 0 and a < 0:
            a, b = -a, -b
        if a * b == 0:
            a, b = abs(a), abs(b)
        if a * b > 0:
            pos.add((a, b))
        AB[(a, b)] = AB.get((a, b), 0) + 1
    t = N - AB.get((0, 0), 0)
    r = 1
    for a, b in pos:
        p = AB[(a, b)]
        n = AB.get((-b, a), 0)
        r *= (pow(2, p, mod) - 1) + (pow(2, n, mod) - 1) + 1
        r %= mod
        t -= (p + n)
    p = AB.get((0, 1), 0)
    n = AB.get((1, 0), 0)
    r *= (pow(2, p, mod) - 1) + (pow(2, n, mod) - 1) + 1
    t -= (p + n)
    r *= pow(2, t, mod)
    r -= 1

    if (0, 0) in AB:
        r += AB[(0, 0)]

    return r % mod

print(main())
while True:
  [x, y] = map(int, input().split())
  if x == y == 0:
    break
  print(min(x, y) max(x, y))

### FIXED CODE ###

while True:
  [x, y] = map(int, input().split())
  if x == y == 0:
    break
  print(min(x, y), max(x, y))
import sys

f = sys.stdin.readline()
xx = f.split(' ')
x = [int(str) for str in xx]

n = x[0]
a = x[1]
b = x[2]

count = 0
sum = 0
while 1:
  for i in range(0, a):
  	count += 1
	if( count > n):
		break
	sum += 1
  for i in range(0, b):
  	count += 1
	if( count > n):
		break
  else:
  	continue
  break

print sum
sys.stdout.flush()


### FIXED CODE ###

import sys

f = sys.stdin.readline()
xx = f.split(' ')
x = [int(str) for str in xx]

n = x[0]
a = x[1]
b = x[2]


ab = a + b

d = int(n / ab)
m = n % ab

if ( a > m):
	sum = a * d + m
else:
	sum = a * d + a

print sum
sys.stdout.flush()
s=input()
i=0
j=len(s)-1
ans=0
while i!=j:
    while s[i]=="x":
        i+=1
        ans+=1
        if i>len(s):break
    if i==j:break
    while s[j]=="x":
        j-=1
        ans+=1
        if j<0:break
    if s[i]!=s[j]:
        ans=-1
        break
    if i==j:break
    i+=1
    j-=1
    if i>j:break
print(ans)

### FIXED CODE ###

s=input()
i=0
j=len(s)-1
ans=0
while i<j:
    while s[i]==s[j]=="x":
        i+=1
        j-=1
        if i>j:break
    if i>j:break    
    while s[i]=="x":
        i+=1
        ans+=1
        if i>j:break
    if i>j:break
    while s[j]=="x":
        j-=1
        ans+=1
        if i>j:break
    if i>j:break
    if s[i]!=s[j]:
        ans=-1
        break
    i+=1
    j-=1
    if i>j:break
print(ans)
N = int(input())
D = sorted(list(map(int,input().split())))
ans = 1
D.append(-1)
if D[0]>0:
    ans = 0
elif D[1]==0:
    ans = 0
else:
    cur = 0
    n1 = 1
    n2 = 1
    for i,d in enumerate(D[1::],1):
        if d == cur:
            n2 += 1
        else:
            nn = (n1**n2)%998244353
            ans *= nn
            n1 = n2
            n2 = 1
            cur = d
print(ans)

### FIXED CODE ###

N = int(input())

if N%2 == 0:
    print(int(N//2-1))
else:
    print(int((N+1)//2-1))
N = 0
for (N<1000 N++)
    if N == [2,4,5,7,9]
        print("h")
    elif N == [0,1,6,8]
        print("p")
    else N == [3]
        print("b")
print ("on")


### FIXED CODE ###

int = input()
if int[-1] == "3":
  	print("bon")
elif int[-1] == "0" or int[-1] == "1" or int[-1] == "6" or int[-1] == "8":
    print("pon")
else:
	print("hon")
A, B, C, K = map(int, input().split())
lst = []
sum = 0
if A <= K:
    sum += 1 * A
else:
    sum += 1 * K

k = K - (A + B)

if (C <= k) and (k > 0):
    sum += -1 * C
elif (c > k) and (k > 0):
    sum += -1 * k

print(sum)

### FIXED CODE ###

A, B, C, K = map(int, input().split())
lst = []
sum = 0
if A <= K:
    sum += 1 * A
else:
    sum += 1 * K

k = K - (A + B)

if (C <= k) and (k > 0):
    sum += -1 * C
elif (C > k) and k > 0:
    sum += -1 * k

print(sum)
ciar = input().split(" ")
W,H,x,y,r = [ciar[0],ciar[1],ciar[2],ciar[3],ciar[4]]
if (x + r) <= W and (x - r) >= 0 :
    if (y + r) <= H and (y - r) >= 0 :
        print("Yes")
else :
    print("No")

### FIXED CODE ###

ciar = input().split()
W = int(ciar[0])
H = int(ciar[1])
x = int(ciar[2])
y = int(ciar[3])
r = int(ciar[4])
if (x + r) <= W and (x - r) >= 0 :
    if (y + r) <= H and (y - r) >= 0 :
        print("Yes")
    else :
        print("No")
else :
    print("No")
N, K = map(int, input().split())
x_list = list(map(int, input().split()))

result = []
for i in range(N-K):
    start = i
    end = i + K 
    result.append(abs(x_list[start] + abs(x_list[end] - x_list[start])))
    result.append(abs(x_list[end]) +  abs(x_list[end] - x_list[start] ))
print(min(result))

### FIXED CODE ###

N, K = map(int, input().split())
x_list = list(map(int, input().split()))

result = []
for i in range(N-(K-1)):
    start = i
    end = i + (K -1)
    result.append(abs(x_list[start]) + abs(x_list[end] - x_list[start]))
    result.append(abs(x_list[end]) + abs(x_list[end] - x_list[start]))
print(min(result))
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

A,B,C,D=map(int, input().split())
LCM=lcm(C,D)
Ac=(A-1)//C
div_C=B//C-Ac
Ad=(A-1)//D
div_D=B//D-Ad
Alcm=(A-1)//LCM
div_CD=B//LCM-Alcm
Ans=(B-A+1)-div_C-div_D+div_CD
print(Ans)

### FIXED CODE ###

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

A,B,C,D=map(int, input().split())

#CとDの最小公倍数
LCM=lcm(C,D)
#A未満でCで割れる個数
Ac=(A-1)//C
#範囲内でCで割れる個数
div_C=B//C-Ac
#A未満でDで割れる個数
Ad=(A-1)//D
#範囲内でDで割れる個数
div_D=B//D-Ad
#A未満でLCMで割れる個数
Alcm=(A-1)//LCM
#範囲内でLCMで割れる個数
div_CD=B//LCM-Alcm
#解答
Ans=(B-A+1)-div_C-div_D+div_CD
print(Ans)
a=int(input())
s=input()
d=input()
z=""
for i in range(a):
  z+=s[i]
  z+=d[i]
print(z)


### FIXED CODE ###

a=int(input())
s,d=input().split()
z=""
for i in range(a):
  z+=s[i]
  z+=d[i]
print(z)
s = input().split()

WtoE = []
wtoec = 0
EtoW = []
etowc = 0

for c in s[1]:
    if c == "W":
        wtoec = wtoec + 1
    WtoE.append(wtoec)

for c in s[1][::-1]:
    if c == "E":
        etowc = etowc + 1
    EtoW.append(etowc)
EtoW.reverse()
print(WtoE)
print(EtoW)

a = []
for i in range(0, int(s[0])):
    ans = WtoE[i] + EtoW[i]
    if WtoE[i] != 0 and s[1][i] == "W" or EtoW[i] != 0 and s[1][i] == "E":
        ans = ans - 1

    a.append(ans)

print(min(a))


### FIXED CODE ###

s = ["", ""]

s[0] = input()
s[1] = input()

WtoE = []
wtoec = 0
EtoW = []
etowc = 0

for c in s[1]:
    if c == "W":
        wtoec = wtoec + 1
    WtoE.append(wtoec)

for c in s[1][::-1]:
    if c == "E":
        etowc = etowc + 1
    EtoW.append(etowc)
EtoW.reverse()

a = []
for i in range(0, int(s[0])):
    ans = WtoE[i] + EtoW[i]
    if WtoE[i] != 0 and s[1][i] == "W" or EtoW[i] != 0 and s[1][i] == "E":
        ans = ans - 1

    a.append(ans)

print(min(a))
n = int(raw_input())
a = map(int, raw_input().split())
b = 0.0
print(a)
for i in range(n):
    b = b + 1/float(a[i])
print(1/b)

### FIXED CODE ###

a = int(raw_input())
s = raw_input()
if a < 3200:
    print('red')
else:
    print(s)
import math
a,b,x=map(int,input().split())
if x>=2/a**2*b:
  print(math.degrees(math.asin(2*(a**2*b-x)/((2*(a**2*b-x)/a**2)**2+a**2)**0.5)))
else:
  print(math.degrees(math.asin(b/((2*x/a/b)**2+b**2)**0.5)))


### FIXED CODE ###

import math
a,b,x=map(int,input().split())
if x>=(a**2*b)/2:
  print(math.degrees(math.acos(a/((2*(a**2*b-x)/a**2)**2+a**2)**0.5)))
else:
  print(math.degrees(math.acos((2*x/a/b)/(((2*x/a/b)**2+b**2)**0.5))))
N,K=map(int,input().split())
H=list(map(int,input().split()))
count=0
for h in H:
  if h>=K:
  count=count+1
print(count)

### FIXED CODE ###

N, K = map(int, input().split())
H = list(map(int, input().split()))
count = 0
for h in H:
    if h >= K:
        count = count+1
print(count)
a,b=mac(int,input().split())
if a<=b:print(a)
else: print(a-1)

### FIXED CODE ###

a,b=map(int,input().split())
if a<=b:print(a)
else: print(a-1)
b=input()
if b='A':
    print('T')
elif b='T':
    print('A')
elif b='C':
    print('G')
else:
    print('C')

### FIXED CODE ###

b=input()
if b=='A':
    print('T')
elif b=='T':
    print('A')
elif b=='C':
    print('G')
else:
    print('C')
from collections import Counter

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

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


def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

for k in range(N):
  sum_k = 0
  temp_c = c.copy()
  temp_c[A[k]] -= 1
  for v in temp_c.values():
    if v > 1:
      sum_k += cmb(v,2)
  print(int(sum_k))

### FIXED CODE ###

from collections import Counter
from scipy.misc import comb

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

num = 0
for v in c.values():
  if v > 1:
      num += comb(v, 2,exact=True)
for k in range(N):
  print(int(num - (c[A[k]]-1)))
def main():
    N = int(input())
    mawari = [[] for _ in range(N)]
    e_num = [0] * N 
    for l in range(N-1):
        i, j = [int(x)-1 for x in input().split()]
        e_num[i] += 1
        e_num[j] += 1
        mawari[i].append((j, l))
        mawari[j].append((i, l))
    look = -1
    for ind, l in enumerate(e_num):
        if l == 1:
            look = ind
            break
    color = [-1]*(N-1)
    mc, c = a(N, 0, look, color, mawari)
    print(mc+1)
    for i in c:
        print(i+1)


def a(N, maxc, look, color, mawari):
    nexts = []
    used = []
    for i,j in mawari[look]:
        if color[j] != -1:
            used.append(color[j])
        else:
            nexts.append((i,j))
    c = 0
    for i,j in nexts:
        while c in used:
            c += 1
        color[j] = c
        maxc = max(c, maxc)
        c += 1
    for i,j in nexts:
        maxc = max(maxc, a(N, maxc, i, color, mawari)[0])
    return maxc, color
    

main()

### FIXED CODE ###

import sys
from collections import deque

# txt = "100000"
# for i in range(99999):
#     txt += "\n" + str(i) +" " +  str(i+1)
# def i():
#     for l in txt.split("\n"):
#         yield l
# input = i().__next__
def main():
    N = int(input())
    mawari = [[] for _ in range(N)]
    e_num = [0] * N 
    for l in range(N-1):
        i, j = [int(x)-1 for x in input().split()]
        e_num[i] += 1
        e_num[j] += 1
        mawari[i].append((j, l))
        mawari[j].append((i, l))
    look = -1
    for ind, l in enumerate(e_num):
        if l == 1:
            look = ind
            break
    color = [-1]*(N-1)
    c_prev = deque([-1])
    to_visit = deque([look])
    maxc = 0
    while len(to_visit)>=1:
        look = to_visit.pop()
        c = 0
        prevc = c_prev.pop()
        for i,j in mawari[look]:
            if color[j] != -1:
                continue
            if c == prevc:
                c += 1
            color[j] = c
            c_prev.append(c)
            to_visit.append(i)
            maxc = max(maxc, c)
            c += 1
        
    # mc, c = a(N, 0, look, color, mawari, -1)
    print(maxc+1)
    for i in color:
        print(i+1)


# def a(N, maxc, look, color, mawari, prev):
#     nexts = mawari[look]
#     c = 0
#     for i,j in nexts:
#         if c == prev:
#             c += 1
#         color[j] = c
#         maxc = max(maxc, a(N, maxc, i, color, mawari, c)[0])
#         c += 1
#     return maxc, color
    

main()
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)
# print(s,t)
if "".join(s) < "".join(t):
    print("Yes")
else:
    print("No")import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)
# print(s,t)
if "".join(s) < "".join(t):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)
# print(s,t)
if "".join(s) < "".join(t):
    print("Yes")
else:
    print("No")
def resolve():
    a, b,c = map(int, input().split())
    if math.sqrt(a) + math.sqrt(b) < math.sqrt(c):
        print("Yes")
    else:
        print("No")

resolve()

### FIXED CODE ###

from decimal import *
def resolve():
    a, b, c = map(int, input().split())
    if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
        print("Yes")
    else:
        print("No")

resolve()
a,b = map(int,input().split())
s = input()
if s[3] == '-' and len(s) == a+b+1:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

a,b = map(int,input().split())
s = input()

if s.count('-') == 1:
    S = s.split('-')
    if len('-'.join(S)) == a+b+1 and len(S[0]) == a and len(S[1]) == b:
        print('Yes')
    else:
        print('No')
else:
    print('No')
n=list(map(int,input()))
s=sum(n)
k=len(n)
print(max(n[0]-1)+9*(k-1),s))

### FIXED CODE ###

n=list(map(int,input()))
s=sum(n)
k=len(n)
print(max((n[0]-1)+9*(k-1),s))
import math
a,b = map(int,input().split())
print(math.floor(a*b))


### FIXED CODE ###

from decimal import Decimal
import math
a,b = map(Decimal,input().split())
ans = a*b
print(math.floor(ans))
N

### FIXED CODE ###

n, k = (int(i) for i in input().split())
if n%2 == 1:
  n = (n//2) + 1
  if k > n:
    print("NO")
  else: print("YES")
else:
  n = n/2
  if k > n:
    print("NO")
  else: print("YES")
import math
q = input().split(" ")
A = int(q[0])
B = q[1].split(".")
b0 = B[0]
b1 = B[1]
if b1[0]=="0":
  b1 = b1[1]


print(A*int(b0) + math.floor(((A*int(b1))/100)

### FIXED CODE ###

q = input().split(" ")
A = int(q[0])
B = q[1].split(".")
#print(B)
b0 = B[0]
b1 = B[1]
if b1[0]=="0":
  b1 = b1[1]

s = str(A*int(b1)//100)
#print(s)
print(A*int(b0) + int(s))
n = int(input())

dic={}
for i in range(n):
    s=''.join(sorted(list(input())))
    dic[s]=dic.get(s,0)+1

ans=0
for key,value in dic.items():
    if value<2:
        continue
    ans+=int(factorial(value) / factorial(2) / factorial(value - 2))
print(ans)

### FIXED CODE ###

from math import factorial
n = int(input())

dic={}
for i in range(n):
    s=''.join(sorted(list(input())))
    dic[s]=dic.get(s,0)+1

ans=0
for key,value in dic.items():
    if value<2:
        continue
    ans+=factorial(value)//(factorial(2)*factorial(value - 2))
print(ans)
second = input()
h = second // 3600
m = second % 3600 // 60
s = second % 60

print("%d : %d : %d " (h, m, s) )

### FIXED CODE ###

second = input()
h = second // 3600
m = second % 3600 // 60
s = second % 60


print( "%d:%d:%d" % (h, m, s) )
a,b = map(int(),input().split())
print(a+b/2)

### FIXED CODE ###

a,b = map(int,input().split())
c = b/2 + a
print(int(c))
N, K = map(int, input().split())
l = [input() for i in range(N+1)]
ans = 0
while True:
  if max(l) >= K:
    l.remove(max(l))
    ans += 1
    
print(ans)
    


### FIXED CODE ###

N, K = map(int, input().split())
li = list(map(int, input().split()))
ans = 0
for i in range(N):
  if li[i] >= K:
    ans += 1
print(ans)
n,q = map(int, input().split())
Q = [0 for i in range(n+1)]
head = 0
tail = 0
def enqueue(x):
    global tail
    Q[tail] = ???
    tail = (tail + 1) % (n + 1)

def dequeue():
    global head
    x,t = Q[head]
    head = (head + 1) % (n + 1)
    return [x,t]
for i in range(n):
    P = input().split()
    enqueue([P[0], int(P[1])])

elaps = 0
while head != tail:
    u,t = dequeue()
    c = min(q, t)
    t -= c
    elaps += c
    if t > 0:
        enqueue([u,t])
    else:
        print(u + " " + str(elaps))

### FIXED CODE ###

n,q = map(int, input().split())
MAX = n + 2
Q = [0 for i in range(MAX)]
head = 0
tail = 0

def enqueue(u, t):
    global tail
    Q[tail] = [u, t]
    tail = (tail + 1) % MAX

def dequeue():
    global head
    x,t = Q[head]
    head = (head + 1) %MAX
    return [x,t]
for i in range(n):
    P = list(input().split())
    enqueue(P[0], int(P[1]))

elaps = 0
while head != tail:
    u,t = dequeue()
    c = min(q, t)
    t -= c
    elaps += c
    if t > 0:
        enqueue(u,t)
    else:
        print(u + " " + str(elaps))
h, w = map(int, input().split())
s = [0] * w
for _ in range(h):
    s[_] = input()

# print(s)
# print(s[1][1])

ok = True
for hi in range(h):
    for wi in range(w):
        if s[hi][wi] == '#':
            drawable = False
            # check
            if hi >= 1:
                drawable = (s[hi-1][wi] == '#') | drawable
            
            if hi <= h-2:
                drawable = (s[hi+1][wi] == '#') | drawable
            
            if wi >= 1:
                drawable = (s[hi][wi-1] == '#') | drawable
            
            if wi <= w-2:
                drawable = (s[hi][wi+1] == '#') | drawable

            # if hi >= 1:
            #     if s[hi-1][wi] == 

            if not drawable:
                ok = False

print("Yes" if ok else "No")


### FIXED CODE ###

h, w = map(int, input().split())
s = [0] * h
for _ in range(h):
    s[_] = input()

# print(s)
# print(s[1][1])

ok = True
for hi in range(h):
    for wi in range(w):
        if s[hi][wi] == '#':
            drawable = False
            # check
            if hi >= 1:
                drawable = (s[hi-1][wi] == '#') | drawable
            
            if hi <= h-2:
                drawable = (s[hi+1][wi] == '#') | drawable
            
            if wi >= 1:
                drawable = (s[hi][wi-1] == '#') | drawable
            
            if wi <= w-2:
                drawable = (s[hi][wi+1] == '#') | drawable

            # if hi >= 1:
            #     if s[hi-1][wi] == 

            if not drawable:
                ok = False

print("Yes" if ok else "No")
A=list(map(int,input().split())) +[0]
ans =0
for i in range(N):
  eated =max(0,A[i]+A[i-1]-x)
  ans +=eated
  A[i]-=eated
  
print(ans)

### FIXED CODE ###

N,x =map(int,input().split())
a=[int(i) for i in input().split()]
ans=0
if a[0] >x:
  ans += (a[0]-x) 
  a[0] -= (a[0]-x) 
  

for i in range(N-1):
  if a[i]+a[i+1] >x:
    ans += ((a[i]+a[i+1])-x)
    a[i+1] -= ((a[i]+a[i+1])-x)
    
  else: continue
    
print(ans)
import math

def lcm(x,y):
    return (x*y)//math.gcd(x,y)

n=int(input())
t=[int(input()) for i in range(n)]

LCM=lcm(t[0],t[1])
for i in range(2,n):
    LCM=lcm(LCM,t[i])

print(LCM)

### FIXED CODE ###

import math

def lcm(x,y):
    return (x*y)//math.gcd(x,y)

n=int(input())
t=[int(input()) for i in range(n)]

LCM=t[0]
for i in range(1,n):
    LCM=lcm(LCM,t[i])

print(LCM)
while 1:
  a,o,b = input().split()
  if o=='?': break
  a,b = int(a,b)
  print(a+b if o=='+' else a-b if o=='-' else a*b if o=='*' else a//b)


### FIXED CODE ###

while 1:
  s = input()
  if '?' in s:break
  print(int(eval(s)))
N = int(input())
M = [[] for _ in range(N)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    u, v = u-1, v-1
    M[u].append((v, w))
    M[v].append((u, w))

visited = [False] * N
color = [0] * N

def dfs(u, c):
    visited[u] = True   #; print('u, c', u, c)
    for vw in M[u]:
        v, w = vw       #; print(vw)
        if visited[v] == False:
            if w%2 == 0:
                color[v] = c * 0b1
            else:
                color[v] = c ^ 0b1
            #print('v, c', v, c)
            dfs(v, color[v])

dfs(u, 0)
for i in range(N):
    print(color[i])

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

N = int(input())
M = [[] for _ in range(N)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    u, v = u-1, v-1
    M[u].append((v, w))
    M[v].append((u, w))

visited = [False] * N
color = [0] * N

def dfs(u, c):
    visited[u] = True   #; print('u, c', u, c)
    for vw in M[u]:
        v, w = vw       #; print(vw)
        if visited[v] == False:
            if w%2 == 0:
                color[v] = c * 0b1
            else:
                color[v] = c ^ 0b1
            #print('v, c', v, c)
            dfs(v, color[v])

dfs(u, 0)
for i in range(N):
    print(color[i])