AtCoder Beginner Contest 096 - Grid Repainting 2

We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j).

Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= #, and to make Square (i, j) white when s_{i, j}= ..

However, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black.

Determine if square1001 can achieve his objective.  

-----Constraints-----
 - H is an integer between 1 and 50 (inclusive).
 - W is an integer between 1 and 50 (inclusive).
 - For every (i, j) (1 \leq i \leq H, 1 \leq j \leq W), s_{i, j} is # or ..

-----Input-----
Input is given from Standard Input in the following format:
H W
s_{1, 1} s_{1, 2} s_{1, 3} ... s_{1, W}
s_{2, 1} s_{2, 2} s_{2, 3} ... s_{2, W}
  :   :
s_{H, 1} s_{H, 2} s_{H, 3} ... s_{H, W}

-----Output-----
If square1001 can achieve his objective, print Yes; if he cannot, print No.

-----Sample Input-----
3 3
.#.
###
.#.

-----Sample Output-----
Yes

One possible way to achieve the objective is shown in the figure below. Here, the squares being painted are marked by stars.

Source: atcoder | Difficulty: EASY


Solutions:
(H, W) = map(int, input().split())
S = ['.' * (W + 2)]
for i in range(H):
	S.append('.' + input() + '.')
S.append('.' * (W + 2))
print('Yes' if all((S[i][j] == '.' or (S[i + 1][j] == '#' or S[i - 1][j] == '#' or S[i][j + 1] == '#' or (S[i][j - 1] == '#')) for i in range(1, H + 1) for j in range(1, W))) else 'No')


(h, w) = list(map(int, input().split()))
dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]
A = [list(input()) for i in range(h)]
for i in range(h):
	for j in range(w):
		if A[i][j] == '#':
			for (q, e) in zip(dx, dy):
				if 0 <= i + q < h and 0 <= j + e < w:
					if A[i + q][e + j] == '#':
						break
			else:
				print('No')
				return
print('Yes')


(h, w) = map(int, input().split())
s = [input() for _ in range(h)]
for i in range(1, h - 1):
	for j in range(1, w - 1):
		if s[i][j] == '#':
			if s[i - 1][j] + s[i + 1][j] + s[i][j - 1] + s[i][j + 1] == '....':
				print('No')
				exit()
print('Yes')


from itertools import product
(H, W) = list(map(int, input().split()))
s = [input() for _ in range(H)]
for (i, j) in product(list(range(H)), list(range(W))):
	if s[i][j] == '.':
		continue
	is_ok = False
	for (di, dj) in ((1, 0), (-1, 0), (0, 1), (0, -1)):
		(ni, nj) = (i + di, j + dj)
		if not (0 <= ni < H and 0 <= nj < W):
			continue
		if s[ni][nj] == '#':
			is_ok = True
	if not is_ok:
		print('No')
		break
else:
	print('Yes')


(H, W) = map(int, input().split())
s = [[''] * W] * H
for i in range(H):
	s[i] = input()
for i in range(1, H - 1):
	for j in range(1, W - 1):
		if s[i - 1][j] == '.' and s[i + 1][j] == '.' and (s[i][j + 1] == '.') and (s[i][j - 1] == '.') and (s[i][j] == '#'):
			print('No')
			exit()
print('Yes')


(H, W) = list(map(int, input().split()))
L = [list(input()) for _ in range(H)]
for i in range(H):
	for j in range(W):
		if L[i][j] == '#':
			if i != 0 and L[i - 1][j] == '#':
				continue
			if i != H - 1 and L[i + 1][j] == '#':
				continue
			if j != 0 and L[i][j - 1] == '#':
				continue
			if j != W - 1 and L[i][j + 1] == '#':
				continue
			print('No')
			return
print('Yes')


(h, w) = map(int, input().split())
l = [input() for i in range(h)]
a = '.' * (w + 2)
ans = 'Yes'
for _ in range(h):
	l[_] = '.' + l[_] + '.'
l.append(a)
l.insert(0, a)
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if l[i][j] == '#' and l[i - 1][j] == '.' and (l[i][j - 1] == '.') and (l[i + 1][j] == '.') and (l[i][j + 1] == '.'):
			ans = 'No'
print(ans)


(h, w) = map(int, input().split())
s = ['.' + input() + '.' for _ in range(h)]
s = ['.' * (w + 2)] + s + ['.' * (w + 2)]
flg = True
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if s[i][j] == '#':
			if all((s[i + _i][j + _j] == '.' for (_i, _j) in [(1, 0), (0, 1), (-1, 0), (0, -1)])):
				flg = False
				break
print('Yes' if flg else 'No')


hw = [int(i) for i in input().split()]
s = ['.' + input() + '.' for i in range(hw[0])]
s = ['.' * (hw[1] + 2)] + s + ['.' * (hw[1] + 2)]
for i in range(1, hw[0] + 1):
	for n in range(1, hw[1] + 1):
		if s[i][n] == '#':
			if s[i + 1][n] == s[i][n + 1] == s[i - 1][n] == s[i][n - 1] == '.':
				print('No')
				exit()
print('Yes')


import sys
input = sys.stdin.readline
(H, W) = map(int, input().split())
vP = ['.' * (W + 2)]
mM = vP + ['.' + input() + '.' for _ in [0] * H] + vP
mD = [(-1, 0), (1, 0), (0, -1), (0, 1)]
for i in range(1, H + 1):
	for j in range(1, W + 1):
		if mM[i][j] == '#' and all((mM[i + x][j + y] == '.' for (x, y) in mD)):
			print('No')
			exit(0)
print('Yes')


from itertools import product
(H, W) = map(int, input().split())
S = [input() for i in range(H)]
isOK = True
for (y, x) in product(range(H), range(W)):
	if S[y][x] == '.':
		continue
	sum = 0
	if 0 < x:
		if S[y][x - 1] == '#':
			sum += 1
	if x < W - 1:
		if S[y][x + 1] == '#':
			sum += 1
	if 0 < y:
		if S[y - 1][x] == '#':
			sum += 1
	if y < H - 1:
		if S[y + 1][x] == '#':
			sum += 1
	if sum == 0:
		isOK = False
if isOK:
	print('Yes')
else:
	print('No')


(h, w) = list(map(int, input().split()))
s = ['.' + input() + '.' for _ in range(h)]
s = ['.' * (w + 2)] + s + ['.' * (w + 2)]
for y in range(1, h + 1):
	for x in range(1, w + 1):
		if s[y][x] == '#' and all((s[y + dy][x + dx] == '.' for (dy, dx) in [(1, 0), (0, 1), (-1, 0), (0, -1)])):
			print('No')
			return
print('Yes')


import sys

def check(i, j, s_list, h, w):
	uesita_list = [-1, 1]
	sayuu_list = [-1, 1]
	for uesita in uesita_list:
		new_i = i + uesita
		if new_i < 0 or new_i > h - 1:
			continue
		if s_list[new_i][j] == '#':
			return True
	for sayuu in sayuu_list:
		new_j = j + sayuu
		if new_j > w - 1 or new_j < 0:
			continue
		if s_list[i][new_j] == '#':
			return True
	return False
input = sys.stdin.readline
(h, w) = list(map(int, input().split()))
s_list = [[0 for _ in range(w)] for _ in range(h)]
for i in range(h):
	w_s_list = input()
	w_s_list = w_s_list.replace('\n', '')
	w_s_list = list(w_s_list)
	for j in range(w):
		s_list[i][j] = w_s_list[j]
for i in range(h):
	for j in range(w):
		s = s_list[i][j]
		if s == '#':
			ok_flag = check(i, j, s_list, h, w)
			if not ok_flag:
				print('No')
				return
print('Yes')


(H, W) = map(int, input().split())
s = ['.' * (W + 2)] + ['.' + input() + '.' for i in range(H)] + ['.' * (W + 2)]
ans = 'Yes'
for h in range(1, H + 1):
	for w in range(1, W + 1):
		if s[h][w] == '#':
			if '#' not in [s[h - 1][w], s[h + 1][w], s[h][w - 1], s[h][w + 1]]:
				ans = 'No'
				break
print(ans)


(h, w) = map(int, input().split())
mat = []
mat.append('.' * (w + 2))
for i in range(h):
	s = input()
	mat.append('.' + s + '.')
mat.append('.' * (w + 2))
for x in range(1, w + 1):
	for y in range(1, h + 1):
		if mat[y][x] == '#' and mat[y - 1][x] == '.' and (mat[y + 1][x] == '.') and (mat[y][x - 1] == '.') and (mat[y][x + 1] == '.'):
			print('No')
			exit()
print('Yes')


def main():
	(H, W) = list(map(int, input().split()))
	ans = 'Yes'
	grid = [['*'] * (W + 2) for _ in range(H + 2)]
	dir = [[1, 0], [-1, 0], [0, 1], [0, -1]]
	for i in range(H):
		S = list(input())
		for j in range(W):
			grid[i + 1][j + 1] = S[j]
	for i in range(H):
		for j in range(W):
			if grid[i + 1][j + 1] == '#':
				flg = True
				for (x, y) in dir:
					if grid[i + 1 + x][j + 1 + y] == '#':
						flg = False
				if flg:
					ans = 'No'
	print(ans)

def __starting_point():
	main()
__starting_point()


(H, W) = list(map(int, input().split()))
sq = [list(input()) for i in range(H)]
for i in range(H):
	for j in range(W):
		if sq[i][j] == '#':
			temp = 0
			if j != 0:
				if sq[i][j - 1] == '#':
					temp += 1
			if j != W - 1:
				if sq[i][j + 1] == '#':
					temp += 1
			if i != 0:
				if sq[i - 1][j] == '#':
					temp += 1
			if i != H - 1:
				if sq[i + 1][j] == '#':
					temp += 1
			if temp == 0:
				print('No')
				return
print('Yes')


import sys

def LI():
	return list(map(int, input().split()))

def LSH(h):
	return [input() for _ in range(h)]
(H, W) = LI()
masu = LSH(H)
for i in range(H):
	for j in range(W):
		ok = 0
		if masu[i][j] == '.':
			continue
		if j + 1 < W:
			if masu[i][j + 1] == '#':
				ok = 1
		if j - 1 >= 0:
			if masu[i][j - 1] == '#':
				ok = 1
		if i + 1 < H:
			if masu[i + 1][j] == '#':
				ok = 1
		if i - 1 >= 0:
			if masu[i - 1][j] == '#':
				ok = 1
		if ok == 0:
			print('No')
			return
print('Yes')


(h, w) = list(map(int, input().split()))
ans = 'Yes'
s = []
for i in range(h):
	s += input().split()
s.insert(0, ''.join(['.'] * (w + 2)))
s = list(map(lambda x: '.' + x + '.', s))
s.insert(len(s), ''.join(['.'] * (w + 2)))
s = list(map(list, s))
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if s[i][j] == '#':
			flg_up = True if s[i - 1][j] == '.' else False
			flg_down = True if s[i + 1][j] == '.' else False
			flg_left = True if s[i][j - 1] == '.' else False
			flg_right = True if s[i][j + 1] == '.' else False
			if flg_up & flg_down & flg_left & flg_right:
				ans = 'No'
				break
	else:
		continue
	break
print(ans)


(h, w) = map(int, input().split())
A = []
A.append('.' * (w + 2))
for i in range(h):
	A.append(list('.' + input() + '.'))
A.append('.' * (w + 2))
f = True
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if A[i][j] == '#' and A[i + 1][j] == '.' and (A[i - 1][j] == '.') and (A[i][j + 1] == '.') and (A[i][j - 1] == '.'):
			f = False
if f:
	print('Yes')
else:
	print('No')


(h, w) = map(int, input().split())
S = ['.' * (w + 2)] + ['.' + input() + '.' for _ in range(h)] + ['.' * (w + 2)]
for i in range(h + 2):
	for j in range(w + 2):
		if S[i][j] == '#':
			for k in range(4):
				if S[i + 1][j] != '#' and S[i][j + 1] != '#' and (S[i - 1][j] != '#') and (S[i][j - 1] != '#'):
					print('No')
					exit()
print('Yes')


(h, w) = map(int, input().split())
s = [input() for _ in range(h)]
ans = 'Yes'
for i in range(h):
	for j in range(w):
		if s[i][j] == '#':
			if (i == 0 or s[i - 1][j] == '.') and (i == h - 1 or s[i + 1][j] == '.') and (j == 0 or s[i][j - 1] == '.') and (j == w - 1 or s[i][j + 1] == '.'):
				ans = 'No'
print(ans)


import sys
import copy
import math
import itertools
import numpy as np
(H, W) = [int(c) for c in input().split()]
s = [list(input()) for c in range(H)]
a = [[1 for c in range(W)] for d in range(H)]
b = [[0 for c in range(W)] for d in range(H)]
for i in range(H):
	for j in range(W):
		if s[i][j] == '#':
			if i - 1 >= 0:
				if s[i - 1][j] == '#':
					a[i][j] = 0
			if j - 1 >= 0:
				if s[i][j - 1] == '#':
					a[i][j] = 0
			if j + 1 < W:
				if s[i][j + 1] == '#':
					a[i][j] = 0
			if i + 1 < H:
				if s[i + 1][j] == '#':
					a[i][j] = 0
		else:
			a[i][j] = 0
		if a[i][j] == 1:
			print('No')
			return
print('Yes')


(y, x) = map(int, input().split())
g = [input() for i in range(y)]
flag = True
for yy in range(1, y - 1):
	for xx in range(1, x - 1):
		if g[yy][xx] == '#':
			if g[yy - 1][xx] == g[yy + 1][xx] == g[yy][xx - 1] == g[yy][xx + 1] == '.':
				flag = False
if flag:
	print('Yes')
else:
	print('No')


(h, w) = map(int, input().split())
s = []
s.append(['.'] * (w + 2))
for i in range(h):
	s.append([a for a in input()])
	s[i + 1].insert(0, '.')
	s[i + 1].append('.')
s.append(['.'] * (w + 2))
check = True
for j in range(1, h + 1):
	for k in range(1, w + 1):
		if s[j][k] == '#':
			if s[j + 1][k] == '.' and s[j - 1][k] == '.' and (s[j][k + 1] == '.') and (s[j][k - 1] == '.'):
				check = False
print('Yes' if check else 'No')


(h, w) = map(int, input().split())
s = [input() for i in range(h)]
for i in range(1, h - 1):
	for j in range(1, w - 1):
		if s[i][j] == '#':
			if s[i + 1][j] == '#' or s[i - 1][j] == '#' or s[i][j + 1] == '#' or (s[i][j - 1] == '#'):
				continue
			else:
				print('No')
				exit()
print('Yes')


(h, w) = map(int, input().split())
ss = [input() for i in range(h)]
sm = ['.' + s + '.' for s in ss]
mm = ['.' * (w + 2)] + sm + ['.' * (w + 2)]
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if mm[i][j] == '#' and mm[i][j - 1] == '.' and (mm[i][j + 1] == '.') and (mm[i - 1][j] == '.') and (mm[i + 1][j] == '.'):
			print('No')
			return
print('Yes')


(h, w) = map(int, input().split())
c = [input() for _ in range(h)]
for i in range(h):
	for j in range(w):
		if c[i][j] == '#':
			upper = c[i - 1][j] == '#' if 0 <= i - 1 else False
			lower = c[i + 1][j] == '#' if i + 1 < h else False
			left = c[i][j - 1] == '#' if 0 <= j - 1 else False
			right = c[i][j + 1] == '#' if j + 1 < w else False
			if not (upper or lower or left or right):
				print('No')
				break
	else:
		continue
	break
else:
	print('Yes')


(h, w) = map(int, input().split())
s = [[0] * (w + 2)] + [[0] + list(input()) + [0] for _ in range(h)] + [[0] * (w + 2)]
for i in range(h + 2):
	for j in range(w + 2):
		if s[i][j] == '#' and s[i + 1][j] != '#' and (s[i - 1][j] != '#') and (s[i][j + 1] != '#') and (s[i][j - 1] != '#'):
			print('No')
			exit()
print('Yes')


(H, W) = list(map(int, input().split()))
M = []
M.append('.' * (W + 2))
M += ['.' + input() + '.' for _ in range(H)]
M.append('.' * (W + 2))
for h in range(1, H + 1):
	for w in range(1, W + 1):
		if M[h][w] == '#' and '....' == M[h][w + 1] + M[h][w - 1] + M[h + 1][w] + M[h - 1][w]:
			print('No')
			exit()
print('Yes')


(H, W) = map(int, input().split())
L = [list(input()) for _ in range(H)]
N = L.count('#')
for i in range(H):
	for j in range(W):
		if L[i][j] == '#':
			if not (i - 1 >= 0 and L[i - 1][j] == '#' or (j - 1 >= 0 and L[i][j - 1] == '#') or (i + 1 < H and L[i + 1][j] == '#') or (j + 1 < W and L[i][j + 1] == '#')):
				print('No')
				exit()
print('Yes')


(h, w) = list(map(int, input().split()))
square = []
for _ in range(h):
	square.append(input())

def check(i, j):
	flg = False
	for (di, dj) in [[-1, 0], [1, 0], [0, -1], [0, 1]]:
		if di + i < 0 or dj + j < 0:
			continue
		if di + i >= h or dj + j >= w:
			continue
		if square[di + i][dj + j] == '#':
			flg = True
	return flg
for i in range(h):
	for j in range(w):
		if square[i][j] == '#':
			if not check(i, j):
				print('No')
				return
print('Yes')


(h, w) = map(int, input().split())
l = [input() for _ in range(h)]
nb = [(0, 1), (1, 0), (0, -1), (-1, 0)]
for i in range(h):
	for j in range(w):
		if l[i][j] == '#':
			for (a, b) in nb:
				if 0 <= i + a <= h - 1 and 0 <= j + b <= w - 1 and (l[i + a][j + b] == '#'):
					break
			else:
				print('No')
				exit()
print('Yes')


(h, w) = map(int, input().split())
a = [input() for _ in range(h)]
flag = False
for i in range(1, h - 1):
	for j in range(1, w - 1):
		if a[i][j] == '#' and a[i][j + 1] == '.' and (a[i + 1][j] == '.') and (a[i - 1][j] == '.') and (a[i][j - 1] == '.'):
			flag = True
if flag:
	print('No')
else:
	print('Yes')


(h, w) = map(int, input().split())
lis = [list(input()) for i in range(h)]
ans = [[0] * w for i in range(h)]
for i in range(h):
	for j in range(w):
		(x, y) = (0, 0)
		if lis[i][j] == '#':
			ans[i][j] = 1
			for a in range(-1, 2):
				if 0 <= i + a < h and lis[i + a][j] == '#' and (a != 0):
					x += 1
			ans[i][j] += x
			for b in range(-1, 2):
				if 0 <= j + b < w and lis[i][j + b] == '#' and (b != 0):
					y += 1
			ans[i][j] += y
			if ans[i][j] == 1:
				print('No')
				return
		else:
			ans[i][j] = 0
print('Yes')


(h, w) = map(int, input().split())
s = [list(input()) for i in range(h)]
for i in range(h):
	s[i].insert(0, '.')
	s[i].append('.')
s.insert(0, ['.'] * (w + 2))
s.append(['.'] * (w + 2))
flag = True
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if s[i][j] == '#':
			if s[i - 1][j] == '#' or s[i + 1][j] == '#' or s[i][j - 1] == '#' or (s[i][j + 1] == '#'):
				continue
			else:
				flag = False
				break
	if flag == False:
		print('No')
		break
else:
	print('Yes')


(H, W) = list(map(int, input().split()))
masu = [['.' for _ in range(W + 2)] for _ in range(H + 2)]
for i in range(H):
	masu[i + 1][1:W + 1] = input()
result = [[0 for _ in range(W)] for _ in range(H)]
for i in range(1, H + 1):
	for j in range(1, W + 1):
		if masu[i][j] == '#':
			x = masu[i - 1][j] + masu[i][j - 1] + masu[i][j + 1] + masu[i + 1][j]
			if x.count('#') == 0:
				print('No')
				return
print('Yes')


import sys
(H, W) = map(int, input().split())
lsHW = [['.' for i in range(W + 2)]]
for i in range(H):
	Sls = ['.'] + list(input()) + ['.']
	lsHW.append(Sls)
lsHW.append(['.' for i in range(W + 2)])
for i in range(1, H + 1):
	for j in range(1, W + 1):
		if lsHW[i][j] == '.':
			continue
		elif not (lsHW[i - 1][j] == '#' or lsHW[i + 1][j] == '#' or lsHW[i][j - 1] == '#' or (lsHW[i][j + 1] == '#')):
			print('No')
			return
print('Yes')


(H, W) = map(int, input().split())
C = ['.' * (W + 2)]
for i in range(H):
	C += ['.' + input() + '.']
C += ['.' * (W + 2)]
result = 'Yes'
for i in range(1, H + 2):
	for j in range(1, W + 2):
		if C[i][j] == '#':
			if '#' not in [C[i + 1][j], C[i - 1][j], C[i][j + 1], C[i][j - 1]]:
				result = 'No'
print(result)


(h, w) = map(int, input().split())
s = eval('input(),' * h)
for i in range(h):
	for j in range(w):
		if s[i][j] == '.':
			continue
		for (y, x) in ((i - 1, j), (i + 1, j), (i, j - 1), (i, j + 1)):
			if h > y >= 0 and w > x >= 0 and (s[y][x] == '#'):
				break
		else:
			print('No')
			exit()
print('Yes')


(h, w) = map(int, input().split())
lis = []
for i in range(h):
	lis.append(list(input()))
for i in range(1, h - 1):
	for j in range(1, w - 1):
		if lis[i][j] == '#':
			if lis[i - 1][j] == '.' and lis[i + 1][j] == '.' and (lis[i][j - 1] == '.') and (lis[i][j + 1] == '.'):
				print('No')
				exit()
print('Yes')


(h, w) = map(int, input().split())
A = [['.'] * (w + 2)]
for i in range(h):
	s = list(input())
	A.append(['.'] + s + ['.'])
A.append(['.'] * (w + 2))
for i in range(2, h + 1):
	for j in range(2, w + 1):
		if A[i][j] == '#' and A[i - 1][j] == '.' and (A[i + 1][j] == '.') and (A[i][j - 1] == '.') and (A[i][j + 1] == '.'):
			print('No')
			exit()
print('Yes')


(h, w) = map(lambda x: int(x), input().split())
s = []
s.append('.' * (w + 2))
for i in range(h):
	s.append('.' + input() + '.')
s.append('.' * (w + 2))
ans = 'Yes'
for i in range(1, h + 2):
	for j in range(1, w + 2):
		if s[i][j] == '#' and s[i - 1][j] == '.' and (s[i + 1][j] == '.') and (s[i][j - 1] == '.') and (s[i][j + 1] == '.'):
			ans = 'No'
print(ans)


(col, row) = [int(x) for x in input().split()]
map_list = [[0] * (row + 2)]
for i in range(col):
	map_list.append(['0'] + list(input()) + ['0'])
map_list.append(map_list[0])

def check(x, y):
	lands = [[x, y]]
	area = 0
	sealine = 0
	while lands:
		(x, y) = lands.pop()
		area += 1
		map_list[y][x] = '2'
		if map_list[y + 1][x] == '#':
			lands.append([x, y + 1])
		elif not map_list[y + 1][x] == '2':
			sealine += 1
		if map_list[y][x + 1] == '#':
			lands.append([x + 1, y])
		elif not map_list[y][x + 1] == '2':
			sealine += 1
		if map_list[y - 1][x] == '#':
			lands.append([x, y - 1])
		elif not map_list[y - 1][x] == '2':
			sealine += 1
		if map_list[y][x - 1] == '#':
			lands.append([x - 1, y])
		elif not map_list[y][x - 1] == '2':
			sealine += 1
		lands = list(map(tuple, lands))
		lands = list(set(lands))
	return area
res = 'Yes'
for i in range(1, col + 1):
	for j in range(1, row + 1):
		if map_list[i][j] == '#':
			if check(j, i) == 1:
				res = 'No'
print(res)


(H, W) = list(map(int, input().split()))
S = ['.' * (W + 2)]
S += ['.' + input() + '.' for i in range(H)]
S += ['.' * (W + 2)]
ng = False
for i in range(1, H + 1):
	for j in range(1, W + 1):
		if S[i][j] != '#':
			continue
		for (y, x) in ((0, 1), (0, -1), (1, 0), (-1, 0)):
			if S[i + y][j + x] == '#':
				break
		else:
			ng = True
print('YNeos'[ng::2])


(h, w) = list(map(int, input().split()))
ans = 'Yes'
s = []
for i in range(h):
	s += input().split()
s = list(map(list, s))
for i in range(h):
	for j in range(w):
		if s[i][j] == '#':
			if i > 0:
				flg_up = False if s[i - 1][j] == '#' else True
			else:
				flg_up = True
			if i < h - 1:
				flg_down = False if s[i + 1][j] == '#' else True
			else:
				flg_down = True
			if j > 0:
				flg_left = False if s[i][j - 1] == '#' else True
			else:
				flg_left = True
			if j < w - 1:
				flg_right = False if s[i][j + 1] == '#' else True
			else:
				flg_right = True
			if flg_up & flg_down & flg_left & flg_right:
				ans = 'No'
				break
	else:
		continue
	break
print(ans)


import sys
input = sys.stdin.readline

def main():
	(H, W) = list(map(int, input().split()))
	field = []
	for _ in range(H):
		tmp = list(input()[:-1])
		field.append(tmp)
	from collections import deque
	digtmp = [(0, 1), (1, 0), (0, -1), (-1, 0)]
	for h in range(H):
		for w in range(W):
			(a, b) = (h, w)
			flag = False
			if field[a][b] == '.':
				continue
			for (dx, dy) in digtmp:
				x = a + dx
				y = b + dy
				if not (0 <= x < H and 0 <= y < W):
					continue
				if field[x][y] == '#':
					flag = True
					continue
			if not flag:
				print('No')
				return
	print('Yes')

def __starting_point():
	main()
__starting_point()


(h, w) = map(int, input().split())
s = []
s.append(['.'] * (w + 2))
for _ in range(h):
	s.append(['.'] + list(input()) + ['.'])
s.append(['.'] * (w + 2))
flag = True
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if s[i][j] == '#' and s[i - 1][j] == '.' and (s[i][j - 1] == '.') and (s[i + 1][j] == '.') and (s[i][j + 1] == '.'):
			flag = False
print('Yes' if flag else 'No')


(H, W) = map(int, input().split())
S = ['.' + input() + '.' for _ in range(H)]
S = ['.' * (W + 2)] + S + ['.' * (W + 2)]
flag = 'Yes'
for i in range(1, H + 1):
	for j in range(1, W + 1):
		if S[i][j] == '#':
			if S[i - 1][j] == '.' and S[i + 1][j] == '.' and (S[i][j - 1] == '.') and (S[i][j + 1] == '.'):
				flag = 'No'
print(flag)


(h, w) = map(int, input().split())
lll = [list('.' * (w + 2))]
G = [list('.' + input() + '.') for _ in range(h)]
G = lll + G + lll
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if G[i][j] == '#' and G[i - 1][j] == G[i + 1][j] == G[i][j - 1] == G[i][j + 1] == '.':
			print('No')
			exit()
print('Yes')


(h, w) = list(map(int, input().split()))
table = [list(input()) for _ in range(h)]
mx = [0, 1, 0, -1]
my = [1, 0, -1, 0]
for i in range(h):
	for j in range(w):
		if table[i][j] == '#':
			for k in range(4):
				(tx, ty) = (j + mx[k], i + my[k])
				if 0 <= tx < w and 0 <= ty < h and (table[ty][tx] == '#'):
					break
			else:
				print('No')
				return
print('Yes')


(H, W) = map(int, input().split())
X = [[[0, 1][a == '#'] for a in input()] + [0] for i in range(H)] + [[0] * (W + 1)]
for i in range(H):
	for j in range(W):
		if X[i][j] == 1 and X[i][j - 1] == X[i - 1][j] == X[i][j + 1] == X[i + 1][j] == 0:
			print('No')
			exit()
print('Yes')


import sys
(h, w) = map(int, input().split())
s = [list(input()) for _ in range(h)]
for i in range(h - 1):
	for j in range(w - 1):
		if s[i][j] == '#':
			if s[i + 1][j] == '#' or s[i - 1][j] == '#' or s[i][j + 1] == '#' or (s[i][j - 1] == '#'):
				pass
			else:
				print('No')
				sys.exit()
print('Yes')


def check(H, W, s, x, y):
	res = False
	if x - 1 >= 0 and s[y][x - 1] == '#':
		res = True
	if x + 1 < W and s[y][x + 1] == '#':
		res = True
	if y - 1 >= 0 and s[y - 1][x] == '#':
		res = True
	if y + 1 < H and s[y + 1][x] == '#':
		res = True
	return res
(H, W) = map(int, input().split())
s = []
for h in range(H):
	s.append(list(input()))
for y in range(H):
	for x in range(W):
		if s[y][x] == '#' and (not check(H, W, s, x, y)):
			print('No')
			return
print('Yes')


(H, W) = map(int, input().split())
S = ['.' * (W + 2)] + ['.' + input() + '.' for h in range(H)] + ['.' * (W + 2)]
for h in range(1, H - 1):
	for w in range(1, W - 1):
		if S[h][w] == '#' and S[h - 1][w] == '.' and (S[h + 1][w] == '.') and (S[h][w - 1] == '.') and (S[h][w + 1] == '.'):
			print('No')
			exit()
print('Yes')


(H, W) = map(int, input().split())
S = [input() + '.' for _ in range(H)] + ['.' * (W + 2)]
print(('Yes', 'No')[any((S[y - 1][x] == S[y + 1][x] == S[y][x - 1] == S[y][x + 1] == '.' for y in range(H) for x in range(W) if S[y][x] == '#'))])


(h, w) = map(int, input().split())
lst = [input() for i in range(h)]
for i in range(h):
	for j in range(w):
		if lst[i][j] == '#':
			if lst[max(0, i - 1)][j] == lst[min(h - 1, i + 1)][j] == lst[i][max(0, j - 1)] == lst[i][min(w - 1, j + 1)] == '.':
				print('No')
				exit()
print('Yes')


(H, W) = map(int, input().split())
S = []
for i in range(H):
	S.append('.' + input() + '.')
S = ['.' * (W + 2)] + S + ['.' * (W + 2)]
flag = 1
for i in range(H):
	for j in range(W):
		if S[i][j] == '#':
			if S[i - 1][j] == '.' and S[i + 1][j] == '.' and (S[i][j - 1] == '.') and (S[i][j + 1] == '.'):
				flag = 0
print('Yes' if flag else 'No')


import numpy as np

def get_num_bomb(arr, i, j):
	temp_arr = np.full([arr.shape[0] + 2, arr.shape[1] + 2], False)
	temp_arr[1:1 + arr.shape[0], 1:1 + arr.shape[1]] = arr[:, :]
	return temp_arr[i + 1, j] + temp_arr[i, j + 1] + temp_arr[i + 2, j + 1] + temp_arr[i + 1, j + 2]

def main():
	(h, w) = tuple([int(x) for x in input().split(' ')])
	arr = []
	ret_arr = [[0] * w for i in range(h)]
	for i in range(h):
		x = list([0 if x == '.' else 1 for x in input()])
		arr.append(x)
	arr = np.array(arr)
	for i in range(h):
		for j in range(w):
			if arr[i, j] == 1:
				if get_num_bomb(arr, i, j) == 0:
					return 'No'
	return 'Yes'
print(main())


(h, w) = map(int, input().split())
a = [input() + '.' for i in range(h)] + ['.' * w]
for i in range(h):
	for j in range(w):
		if a[i][j] == '#':
			if any([a[i + 1][j] == a[i][j + 1] == a[i - 1][j] == a[i][j - 1] == '.']):
				print('No')
				break
	else:
		continue
	break
else:
	print('Yes')


(H, W) = map(int, input().split())
S = []
for _ in range(H):
	s = list(input())
	S.append(s)
cnt = [[0] * W for _ in range(H)]
for h in range(H):
	c = 0
	for w in range(W):
		if S[h][w] == '#':
			c += 1
		else:
			if c == 1:
				cnt[h][w - 1] = 1
			c = 0
	if c == 1:
		cnt[h][w] = 1
ans = 'Yes'
for w in range(W):
	c = 0
	for h in range(H):
		if S[h][w] == '#':
			c += 1
		else:
			if c == 1:
				if cnt[h - 1][w] == 1:
					ans = 'No'
					break
			c = 0
	if c == 1:
		if cnt[h][w] == 1:
			ans = 'No'
			break
print(ans)


(h, w) = [int(x) for x in input().split()]
s_list = [input() for _ in range(h)]
iso_flag = [[True] * w for _ in range(h)]
for i in range(h):
	for j in range(w):
		if s_list[i][j] == '.':
			continue
		flag_r = True
		if j < w - 1 and s_list[i][j + 1] == '#':
			flag_r = iso_flag[i][j + 1] = False
		flag_d = True
		if i < h - 1 and s_list[i + 1][j] == '#':
			flag_d = iso_flag[i + 1][j] = False
		if iso_flag[i][j] and flag_r and flag_d:
			print('No')
			return
print('Yes')


(h, w) = map(int, input().split())
a = ['.' * (w + 2)]
for i in range(h):
	arr = '.' + str(input()) + '.'
	a.append(arr)
a.append('.' * (w + 2))
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if a[i][j] == '#' and a[i][j - 1] == a[i][j + 1] == a[i + 1][j] == a[i - 1][j] == '.':
			print('No')
			exit()
print('Yes')


(h, w) = map(int, input().split())
l = ['.' * (w + 2)] + list(('.' + (input() + '.') for _ in range(h))) + ['.' * (w + 2)]
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if l[i][j] == '#':
			if l[i - 1][j] == '#' or l[i + 1][j] == '#' or l[i][j + 1] == '#' or (l[i][j - 1] == '#'):
				continue
			else:
				print('No')
				exit()
print('Yes')


(h, w) = map(int, input().split())
S = [['.'] * (w + 2)]
for i in range(h):
	S.append(['.'] + list(input()) + ['.'])
S.append(['.'] * (w + 2))
for i in range(h + 2):
	for j in range(w + 2):
		if S[i][j] == '#':
			if S[i + 1][j] == '.' and S[i - 1][j] == '.' and (S[i][j + 1] == '.') and (S[i][j - 1] == '.'):
				print('No')
				quit()
print('Yes')


(h, w) = map(int, input().split())
p = [['.'] * (w + 2)] + [['.'] + list(map(str, input())) + ['.'] for i in range(h)] + [['.'] * (w + 2)]
print('Yes' if all([any([p[i + x[0]][I + x[1]] == '#' for x in [[0, 1], [0, -1], [1, 0], [-1, 0]]]) for I in range(1, w + 1) for i in range(1, h + 1) if p[i][I] == '#']) else 'No')


(h, w) = map(int, input().split())
S = []
for i in range(h):
	S.append(input())
ans = 'Yes'
for i in range(1, h - 1):
	for j in range(1, w - 1):
		if S[i][j] == '#' and S[i + 1][j] == '.' and (S[i - 1][j] == '.') and (S[i][j + 1] == '.') and (S[i][j - 1] == '.'):
			ans = 'No'
print(ans)


(H, W) = map(lambda x: int(x) + 2, input().split())
grid = '.' * W
for _ in range(H - 2):
	grid += '.' + input() + '.'
grid += '.' * W
Flag = True
move_list = [1, -1, W, -W]
for i in range(1, H - 1):
	for j in range(1, W - 1):
		if grid[i * W + j] == '#' and all((grid[i * W + j + move] == '.' for move in move_list)):
			Flag = False
			break
if Flag:
	print('Yes')
else:
	print('No')


(H, W) = list(map(int, input().split()))
S = ['.' * (W + 2)]
S += ['.' + input() + '.' for i in range(H)]
S += ['.' * (W + 2)]
for i in range(1, H + 1):
	for j in range(1, W + 1):
		if S[i][j] != '#':
			continue
		for (y, x) in ((0, 1), (0, -1), (1, 0), (-1, 0)):
			if S[i + y][j + x] == '#':
				break
		else:
			print('No')
			return
print('Yes')


(h, w) = map(int, input().split())
s = ['.' + input() + '.' for i in range(h)]
s = ['.' * (w + 2)] + s + ['.' * (w + 2)]
flag = 0
for i in range(h):
	for j in range(w):
		if s[i][j] == '#':
			if s[i - 1][j] == '.' and s[i + 1][j] == '.' and (s[i][j - 1] == '.') and (s[i][j + 1] == '.'):
				flag = 1
print('Yes' if flag == 0 else 'No')


(h, w) = map(int, input().split())
S = [list(input()) for _ in range(h)]
drc = [[0, 1], [0, -1], [1, 0], [-1, 0]]
for i in range(h):
	for j in range(w):
		if S[i][j] == '#':
			if all([S[i + y][j + x] == '.' for (x, y) in drc if 0 <= j + x < w and 0 <= i + y < h]):
				print('No')
				exit()
print('Yes')


import sys
(h, w) = map(int, input().split())
s = ['.' * (w + 2)] + ['.' + input() + '.' for i in range(h)] + ['.' * (w + 2)]
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if s[i][j] == '#':
			a = s[i][j - 1] + s[i][j + 1] + s[i - 1][j] + s[i + 1][j]
			if a.count('#') == 0:
				print('No')
				sys.exit()
else:
	print('Yes')


(H, W) = map(int, input().split())
s = [list(input()) for _ in range(H)]
jougesayuu = [(-1, 0), (1, 0), (0, -1), (0, 1)]
check = True
for i in range(H):
	for j in range(W):
		if s[i][j] == '#':
			flag = False
			for (n, m) in jougesayuu:
				(ni, nj) = (i + n, j + m)
				if ni < 0 or H <= ni or nj < 0 or (W <= nj):
					continue
				if s[ni][nj] == '#':
					flag = True
			if not flag:
				check = False
print('Yes' if check else 'No')


(H, W) = map(int, input().split())
s = ['.' * (W + 2)] + ['.' + input() + '.' for _ in range(H)] + ['.' * (W + 2)]
for hi in range(1, H + 1):
	for wi in range(1, W + 1):
		if s[hi][wi] == '.':
			continue
		if s[hi - 1][wi] == '.' and s[hi + 1][wi] == '.':
			if s[hi][wi - 1] == '.' and s[hi][wi + 1] == '.':
				print('No')
				exit()
print('Yes')


(h, w) = map(int, input().split())
s = []
for i in range(h):
	S = str(input())
	s.append(S)
ans = 1
for i in range(1, h - 1):
	for j in range(1, w - 1):
		if s[i][j] == '#':
			if s[i - 1][j] != '#' and s[i + 1][j] != '#' and (s[i][j + 1] != '#') and (s[i][j - 1] != '#'):
				ans = 0
if ans == 1:
	print('Yes')
else:
	print('No')


(h, w) = map(int, input().split())
s = [list(input()) for _ in range(h)]
for i in range(h):
	for j in range(w):
		if s[i][j] == '#':
			c = 0
			for (ni, nj) in [(i + 1, j), (i, j + 1), (i - 1, j), (i, j - 1)]:
				if 0 <= ni < h and 0 <= nj < w and (s[ni][nj] == '#'):
					c += 1
			if c == 0:
				print('No')
				return
print('Yes')


(h, w) = map(int, input().split())
s = [list(input()) for i in range(h)]
ans = 'Yes'
for i in range(1, h - 1):
	for j in range(1, w - 1):
		if s[i][j] == '#' and s[i - 1][j] == '.' and (s[i][j - 1] == '.') and (s[i + 1][j] == '.') and (s[i][j + 1] == '.'):
			ans = 'No'
print(ans)


(H, W) = map(int, input().split())
s = [input() for i in range(H)]
for y in range(H):
	for x in range(W):
		if x - 1 < 0 or y - 1 < 0 or x + 1 > W - 1 or (y + 1 > H - 1):
			continue
		if s[y][x] == '#' and s[y + 1][x] != '#' and (s[y - 1][x] != '#') and (s[y][x + 1] != '#') and (s[y][x - 1] != '#'):
			print('No')
			exit()
print('Yes')


(h, w) = map(int, input().split())
s = ['.' * (w + 2)] + ['.' + input() + '.' for _ in range(h)] + ['.' * (w + 2)]
ans = 'Yes'
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if s[i][j] == '#':
			if '#' not in {s[i - 1][j], s[i + 1][j], s[i][j - 1], s[i][j + 1]}:
				ans = 'No'
				break
				break
print(ans)


(H, W) = map(int, input().split())
list = ['.' + input() + '.' for i in range(H)]
list = ['.' * (W + 2)] + list + ['.' * (W + 2)]
a = 0
for h in range(H):
	for w in range(W):
		if list[h][w] == '#':
			if list[h + 1][w] == '.' and list[h - 1][w] == '.' and (list[h][w - 1] == '.') and (list[h][w + 1] == '.'):
				a = 1
print('Yes' if a == 0 else 'No')


(H, W) = map(int, input().split())
grid = []
for i in range(H):
	grid.append([s for s in input()])
fail_flg = False
for i in range(H):
	if fail_flg:
		break
	for j in range(W):
		r_ij = grid[i][j]
		if r_ij == '.':
			continue
		else:
			c_ij = 0
			if 0 <= i <= H - 1 and 1 <= j <= W - 1:
				if grid[i][j - 1] == '#':
					c_ij += 1
			if 0 <= i <= H - 1 and 0 <= j <= W - 2:
				if grid[i][j + 1] == '#':
					c_ij += 1
			if 1 <= i <= H - 1 and 0 <= j <= W - 1:
				if grid[i - 1][j] == '#':
					c_ij += 1
			if 0 <= i <= H - 2 and 0 <= j <= W - 1:
				if grid[i + 1][j] == '#':
					c_ij += 1
			if c_ij == 0:
				fail_flg = True
				break
if fail_flg:
	print('No')
else:
	print('Yes')


(h, w) = map(int, input().split())
s = ['.' * (w + 2)]
for i in range(h):
	s.append('.' + input() + '.')
s.append('.' * (w + 2))
ans = 'Yes'
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if s[i][j] == '.':
			continue
		if s[i - 1][j] + s[i + 1][j] + s[i][j - 1] + s[i][j + 1] == '....':
			ans = 'No'
print(ans)


(H, W) = map(int, input().split())
s = []
for i in range(H):
	s.append(input())
for y in range(H - 1):
	for x in range(W):
		if s[y][x] == '#':
			if s[y - 1][x] == '#' or s[y + 1][x] == '#' or s[y][x - 1] == '#' or (s[y][x + 1] == '#'):
				pass
			else:
				print('No')
				exit()
print('Yes')


import itertools
(h, w) = map(int, input().split())
s = [input() for i in range(h)]
for (i, j) in itertools.product(range(h), range(w)):
	if s[i][j] == '#' and (i == 0 or s[i - 1][j] == '.') and (j == 0 or s[i][j - 1] == '.') and (i == h - 1 or s[i + 1][j] == '.') and (j == w - 1 or s[i][j + 1] == '.'):
		print('No')
		break
else:
	print('Yes')


import sys
input = sys.stdin.readline
d = '.'
dn = '#'

def isPaintable(h, w, x, y, canvas):
	if x > 0:
		if canvas[y][x - 1] == dn:
			return True
	if x < w - 1:
		if canvas[y][x + 1] == dn:
			return True
	if y > 0:
		if canvas[y - 1][x] == dn:
			return True
	if y < h - 1:
		if canvas[y + 1][x] == dn:
			return True
	return False

def main():
	ans = 'Yes'
	(h, w) = map(int, input().split())
	canvas = []
	for _ in range(h):
		s = list(input().rstrip('\n'))
		canvas.append(s)
	for y in range(h):
		if ans == 'No':
			break
		for x in range(w):
			if canvas[y][x] == dn and (not isPaintable(h, w, x, y, canvas)):
				ans = 'No'
				break
	print(ans)

def __starting_point():
	main()
__starting_point()


(h, w) = list(map(int, input().split()))
s = [list(input()) for _ in range(h)]
dxy = [(1, 0), (0, 1), (-1, 0), (0, -1)]
ans = True
for i in range(h):
	for j in range(w):
		cnt = 0
		if s[i][j] == '#':
			for (p, q) in dxy:
				if not (0 <= i + p < h and 0 <= j + q < w):
					cnt += 1
					continue
				elif s[i + p][j + q] == '.':
					cnt += 1
				else:
					continue
		if cnt == 4:
			ans = False
print('Yes' if ans == True else 'No')


(h, w) = map(int, input().split())
s = [['.'] * (w + 2)]
for _ in range(h):
	s.append(['.'] + list(input()) + ['.'])
s.append(['.'] * (w + 2))
for y in range(1, h + 1):
	for x in range(1, w + 1):
		if s[y][x] == '#' and s[y - 1][x] == '.' and (s[y + 1][x] == '.') and (s[y][x - 1] == '.') and (s[y][x + 1] == '.'):
			print('No')
			exit()
print('Yes')


(H, W) = map(int, input().split())
C = [list(input()) for i in range(H)]
for i in range(H):
	for j in range(W):
		if C[i][j] == '#':
			if (i > 0 and C[i - 1][j] == '.') and (i < H - 1 and C[i + 1][j] == '.') and (j > 0 and C[i][j - 1] == '.') and (j < H - 1 and C[i][j + 1] == '.'):
				print('No')
				exit()
print('Yes')


(h, w) = map(int, input().split())
s = [list(map(str, list(input()))) for i in range(h)]
for i in range(1, h - 1):
	for j in range(1, w - 1):
		if s[i][j] == '#':
			if not (s[i + 1][j] == '#' or s[i - 1][j] == '#' or s[i][j + 1] == '#' or (s[i][j - 1] == '#')):
				print('No')
				exit()
print('Yes')


(h, w) = map(int, input().split())
k = [list(input()) for i in range(h)]
ans = True
for i in range(1, h - 2):
	for j in range(1, w - 2):
		if k[i][j] == '#' and k[i - 1][j] == '.' and (k[i][j - 1] == '.') and (k[i + 1][j] == '.') and (k[i][j + 1] == '.'):
			ans = False
if ans:
	print('Yes')
else:
	print('No')


(H, W) = map(int, input().split())
A = [input() for i in range(H)]
f = True
for i in range(H):
	for j in range(W):
		if A[i][j] == '#':
			g = False
			for (a, b) in [(-1, 0), (1, 0), (0, 1), (0, -1)]:
				if 0 <= i + a < H and 0 <= j + b < W:
					if A[i + a][j + b] == '#':
						g = True
			if not g:
				f = False
print('Yes' if f else 'No')


(h, w) = map(int, input().split())
s = [input() for _ in range(h)]
flag = 1
nx = [1, 0, -1, 0]
ny = [0, 1, 0, -1]
for y in range(h):
	for x in range(w):
		if s[y][x] == '#':
			for i in range(4):
				(tx, ty) = (x + nx[i], y + ny[i])
				if 0 <= ty and ty < h and (0 <= tx) and (tx < w):
					if s[ty][tx] == '#':
						break
			else:
				print('No')
				exit()
print('Yes')


(h, w) = list(map(int, input().split()))
table = [input() for _ in range(h)]
step = [0, 1, 0, -1, 0]
for i in range(h):
	for j in range(w):
		if table[i][j] == '.':
			continue
		flag = False
		for k in range(4):
			(ny, nx) = (i + step[k], j + step[k + 1])
			if nx < 0 or nx == w or ny < 0 or (ny == h):
				continue
			if table[ny][nx] == '#':
				flag = True
		if flag == False:
			print('No')
			return
print('Yes')


(H, W) = map(int, input().split())
S = ['.' * (W + 2)] + ['.' + input() + '.' for _ in range(H)] + ['.' * (W + 2)]
for y in range(1, H + 1):
	for x in range(1, W + 1):
		if S[y][x] == '#' and (S[y - 1][x] + S[y + 1][x] + S[y][x - 1] + S[y][x + 1]).count('#') == 0:
			print('No')
			exit()
print('Yes')


(H, W) = list(map(int, input().split()))
m = []
for i in range(H):
	s = input()
	t = []
	for i in s:
		t.append(1 if i == '#' else 0)
	m.append(t)
for i in range(H):
	for j in range(W):
		if m[i][j] == 0:
			continue
		count = 0
		if i != 0:
			count += m[i - 1][j]
		if i != H - 1:
			count += m[i + 1][j]
		if j != 0:
			count += m[i][j - 1]
		if j != W - 1:
			count += m[i][j + 1]
		if count > 0:
			continue
		else:
			print('No')
			return
print('Yes')


(H, W) = map(int, input().split())
s = [list(input()) for i in range(H)]
for i in range(H):
	for j in range(W):
		if s[i][j] == '#':
			if s[max(0, i - 1)][j] == '.' and s[min(H - 1, i + 1)][j] == '.' and (s[i][max(0, j - 1)] == '.') and (s[i][min(W - 1, j + 1)] == '.'):
				print('No')
				exit()
print('Yes')


(h, w) = list(map(int, input().split()))
ans = 'Yes'
s = []
for i in range(h):
	s += input().split()
s.insert(0, ''.join(['.'] * (w + 2)))
s = list(map(lambda x: '.' + x + '.', s))
s.insert(len(s), ''.join(['.'] * (w + 2)))
s = list(map(list, s))
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if (s[i][j] == '#') & (s[i - 1][j] == '.') & (s[i + 1][j] == '.') & (s[i][j - 1] == '.') & (s[i][j + 1] == '.'):
			ans = 'No'
			break
	else:
		continue
	break
print(ans)


(h, w) = map(int, input().split())
field = ['.' * (w + 2)] + ['.' + input() + '.' for i in range(h)] + ['.' * (w + 2)]
flag = 0
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if field[i][j] == '#':
			if '#' not in [field[i - 1][j], field[i + 1][j], field[i][j - 1], field[i][j + 1]]:
				flag = 1
				break
if flag == 0:
	print('Yes')
else:
	print('No')


import sys
(h, w) = map(int, input().split())
s = [[0] * (w + 2)] + [[0] + list(map(int, list(input().replace('#', '1').replace('.', '0')))) + [0] for i in range(h)] + [[0] * (w + 2)]
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if s[i][j] == 1:
			if s[i - 1][j] + s[i + 1][j] + s[i][j - 1] + s[i][j + 1] == 0:
				print('No')
				sys.exit()
print('Yes')


(H, W) = map(int, input().split())
s = [input() for _ in range(H)]
import sys
for j in range(1, H - 1):
	for i in range(1, W - 1):
		if s[j][i] == '#':
			if s[j][i - 1] == '#':
				pass
			elif s[j - 1][i] == '#':
				pass
			elif s[j][i + 1] == '#':
				pass
			elif s[j + 1][i] == '#':
				pass
			else:
				print('No')
				return
print('Yes')


(h, w) = map(int, input().split())
grid = [['.'] * (w + 2)] + [list('.' + input() + '.') for i in range(h)] + [['.'] * (w + 2)]
for s in range(1, 1 + h):
	for t in range(1, 1 + w):
		if grid[s][t] == '#' and all([grid[s + x][t + y] == '.' for (x, y) in ([0, -1], [0, 1], [1, 0], [-1, 0])]):
			print('No')
			exit()
print('Yes')


import sys
(H, W) = list(map(int, input().split()))
l = []
for i in range(H):
	l.append(list(input()))
for i in range(H):
	for j in range(W):
		if l[i][j] == '.':
			pass
		else:
			count = 0
			if i > 0 and l[i - 1][j] == '#':
				count += 1
			if i < H - 1 and l[i + 1][j] == '#':
				count += 1
			if j > 0 and l[i][j - 1] == '#':
				count += 1
			if j < W - 1 and l[i][j + 1] == '#':
				count += 1
			if count == 0:
				print('No')
				return
print('Yes')


import sys
(h, w) = map(int, input().split())
mat = ['.' + input() + '.' for _ in range(h)]
mat = ['.' * (w + 2)] + mat + ['.' * (w + 2)]
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if mat[i][j] == '#':
			if mat[i + 1][j] == '.' and mat[i - 1][j] == '.' and (mat[i][j + 1] == '.') and (mat[i][j - 1] == '.'):
				print('No')
				sys.exit()
print('Yes')


import re
import copy

def accept_input():
	(H, W) = list(map(int, input().split()))
	S = []
	for _ in range(H):
		S.append(input())
	return (H, W, S)

def process(s):
	if s == '#':
		return 1
	else:
		return 0
(H, W, S) = accept_input()
arr1 = [(-1, -1), (-1, 0), (-1, 1), (1, -1), (1, 0), (1, 1), (0, 1), (0, -1)]
arr = [(-1, 0), (1, 0), (0, 1), (0, -1)]
new_S = copy.deepcopy(S)
g = 0
b = 0
for i in range(H):
	for j in range(W):
		if new_S[i][j] == '#':
			bl = 0
			for idou in arr:
				if i + idou[0] == -1 or i + idou[0] == H:
					continue
				elif j + idou[1] == -1 or j + idou[1] == W:
					continue
				elif new_S[i + idou[0]][j + idou[1]] == '#':
					bl = 1
			if bl != 1:
				b = 1
				break
	if b == 1:
		break
if b == 1:
	print('No')
else:
	print('Yes')


(H, W) = input().split()
dummy_list = ['.'] * (int(W) + 2)
square_list = []
square_list.append(dummy_list)
for i in range(int(H)):
	wide_list = ['.']
	wide_list = wide_list + list(input())
	wide_list.append('.')
	square_list.append(wide_list)
square_list.append(dummy_list)
ans = 'Yes'
for i in range(1, int(H) + 1):
	for j in range(1, int(W) + 1):
		before_list = square_list[i - 1]
		center_list = square_list[i]
		after_list = square_list[i + 1]
		if center_list[j] == '.':
			continue
		if before_list[j] == '.' and center_list[j - 1] == '.' and (center_list[j + 1] == '.') and (after_list[j] == '.'):
			ans = 'No'
print(ans)


from itertools import product
from collections import deque
import numpy as np

class Grid:

	def __init__(self, grid, w=0, h=0, function=lambda x: x):
		self.w = w = w if w else len(grid[0])
		self.h = h = h if h else len(grid)
		dtype = type(function(grid[0][0]))
		self.grid = np.empty((h, w), dtype=dtype)
		for (i, row) in zip(range(h), grid):
			for (j, val) in zip(range(w), row):
				self.grid[i][j] = function(val)

	def is_valid_x(self, x):
		return 0 <= x < self.w

	def is_valid_y(self, y):
		return 0 <= y < self.h

	def is_valid_xy(self, x, y):
		return self.is_valid_x(x) and self.is_valid_y(y)

	def __iter__(self):
		return iter(self.grid)

	def __repr__(self):
		return '\n'.join([' '.join(map(str, row)) for row in self.grid]) + '\n'

	def __getitem__(self, x):
		return self.grid[x]

	def __setitem__(self, x, val):
		self.grid[x] = val

def dfs(grid, root):
	stack = [root]
	(x, y) = root
	grid[y, x] = '!'
	while stack:
		(x, y) = stack.pop()
		yield (x, y)
		for (dx, dy) in zip([1, 0, -1, 0], [0, 1, 0, -1]):
			(nx, ny) = (x + dx, y + dy)
			if grid.is_valid_xy(nx, ny) and grid[ny, nx] == '#':
				stack.append((nx, ny))
				grid[ny, nx] = '!'
(h, w) = map(int, input().split())
grid = Grid([input() for s in range(h)])
for (y, x) in product(range(h), range(w)):
	if grid[y, x] == '#':
		if len(list(dfs(grid, (x, y)))) == 1:
			print('No')
			break
else:
	print('Yes')


(H, W) = map(int, input().split())
S = [input() for _ in range(H)]
for i in range(1, H - 1):
	for j in range(1, W - 1):
		if S[i][j] == '#':
			if S[i + 1][j] == '#' or S[i][j + 1] == '#' or S[i - 1][j] == '#' or (S[i][j - 1] == '#'):
				continue
			else:
				print('No')
				exit()
print('Yes')


(h, w) = map(int, input().split())
l = [input() for i in range(h)]
ans = 'Yes'
for i in range(1, h - 1):
	for j in range(1, w - 1):
		if l[i][j] == '#':
			if l[i - 1][j] == l[i + 1][j] == l[i][j - 1] == l[i][j + 1] == '.':
				ans = 'No'
print(ans)


(h, w) = map(int, input().split())
g = [input() for _ in range(h)]
for x in range(1, h - 1):
	for y in range(1, w - 1):
		if g[x][y] == '#' and all((g[x + dx][y + dy] == '.' for (dx, dy) in ((1, 0), (0, 1), (-1, 0), (0, -1)))):
			print('No')
			exit()
print('Yes')


(h, w) = map(int, input().split())
S = ['.' + input() + '.' for i in range(h)]
S = ['.' * (w + 2)] + S + ['.' * (w + 2)]
f = True
for i in range(h):
	for j in range(w):
		if S[i][j] == '#':
			if S[i - 1][j] == '.' and S[i][j - 1] == '.' and (S[i + 1][j] == '.') and (S[i][j + 1] == '.'):
				f = False
print('Yes' if f else 'No')


(h, w) = map(int, input().split())
c = tuple((tuple((0 if i == '.' else 1 for i in input())) for _ in range(h)))
for i in range(h):
	for j in range(w):
		if c[i][j]:
			T = c[i - 1][j] if 0 <= i - 1 else 0
			B = c[i + 1][j] if i + 1 < h else 0
			L = c[i][j - 1] if 0 <= j - 1 else 0
			R = c[i][j + 1] if j + 1 < w else 0
			if not (T or B or L or R):
				print('No')
				break
	else:
		continue
	break
else:
	print('Yes')


(h, w) = map(int, input().split())
s = [input() for i in range(h)]
for i in range(h):
	for j in range(w):
		if s[i][j] == '#':
			top = max(0, i - 1)
			bottom = min(h - 1, i + 1)
			right = min(w - 1, j + 1)
			left = max(0, j - 1)
			if s[i][right] == s[i][left] == s[top][j] == s[bottom][j] == '.':
				print('No')
				exit()
print('Yes')


(H, W) = map(int, input().split())
L = list((list(input()) for _ in range(H)))
for h in range(H):
	for w in range(W):
		if L[h][w] == '#':
			if not any((0 <= h + d <= H - 1 and L[h + d][w] == '#' or (0 <= w + d <= W - 1 and L[h][w + d] == '#') for d in [-1, 1])):
				print('No')
				exit()
print('Yes')


(H, W) = map(int, input().split())
picture = [input() for _ in range(H)]
for i in range(H):
	for j in range(W):
		if picture[i][j] == '#':
			if i == 0 or picture[i - 1][j] == '.':
				if j == 0 or picture[i][j - 1] == '.':
					if i == H - 1 or picture[i + 1][j] == '.':
						if j == W - 1 or picture[i][j + 1] == '.':
							print('No')
							exit()
print('Yes')


(H, W) = map(int, input().split())
S = [0] * (H + 2)
for i in range(1, H + 1):
	S[i] = '.' + input() + '.'
S[0] = '.' * (W + 2)
S[H + 1] = '.' * (W + 2)
for i in range(1, H + 1):
	for j in range(1, W + 1):
		if S[i][j] == '#':
			check = [S[i - 1][j], S[i][j - 1], S[i + 1][j], S[i][j + 1]]
			if '#' not in check:
				print('No')
				exit()
print('Yes')


(h, w) = map(int, input().split())
SW = [input() for _ in range(h)]
for i in range(1, h - 1):
	for j in range(1, w - 1):
		if SW[i][j] == '#':
			if SW[i - 1][j] == '#' or SW[i + 1][j] == '#' or SW[i][j - 1] == '#' or (SW[i][j + 1] == '#'):
				pass
			else:
				print('No')
				exit()
print('Yes')


(H, W) = map(int, input().split())
S = [input() for _ in range(H)]
d = [-1, 0, 1, 0, -1]
b = 0
for h in range(H):
	for w in range(W):
		if S[h][w] == '.':
			continue
		if any((S[h + x][w + y] == '#' for (x, y) in zip(d, d[1:]) if 0 <= h + x < H and 0 <= w + y < W)):
			continue
		b = 1
print('YNeos'[b::2])


(h, w) = map(int, input().split())
a = ['.' * (w + 2)]
for i in range(h):
	a.append('.' + input() + '.')
a.extend(['.' * (w + 2)])
flg = 0
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if a[i][j] == '#':
			if a[i - 1][j] == '.' and a[i][j - 1] == '.' and (a[i + 1][j] == '.') and (a[i][j + 1] == '.'):
				flg = 1
if flg == 0:
	print('Yes')
else:
	print('No')


(h, w) = map(int, input().split())
S = []
flag = True
for i in range(h):
	r = list(input())
	S.append(r)
for i in range(0, h - 1):
	for j in range(0, w - 1):
		if S[i][j] == '#' and S[i - 1][j] == '.' and (S[i][j - 1] == '.') and (S[i + 1][j] == '.') and (S[i][j + 1] == '.'):
			flag = False
if flag:
	print('Yes')
else:
	print('No')


(h, w) = map(int, input().split())
t = '.' * (w + 2)
b = [t]
for i in range(h):
	s = str(input())
	s = '.' + s + '.'
	b.append(s)
b.append(t)
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if b[i][j] == '#':
			if all([b[i - 1][j] == '.', b[i + 1][j] == '.', b[i][j - 1] == '.', b[i][j + 1] == '.']):
				print('No')
				exit()
print('Yes')


(H, W) = map(int, input().split())
L = ['.' + input() + '.' for _ in range(H)]
L = ['.' * (W + 2)] + L + ['.' * (W + 2)]
for i in range(1, H + 1):
	for j in range(1, W + 1):
		if L[i][j] == '#':
			l = [L[i - 1][j], L[i + 1][j], L[i][j - 1], L[i][j + 1]]
			if '#' not in l:
				print('No')
				break
	else:
		continue
	break
else:
	print('Yes')


(h, w) = map(int, input().split())
F = [list(input()) for _ in range(h)]
for i in range(h):
	for j in range(w):
		cnt = 0
		if F[i][j] == '#':
			if 0 <= i - 1 < h:
				if F[i - 1][j] == '#':
					cnt += 1
			if 0 <= i + 1 < h:
				if F[i + 1][j] == '#':
					cnt += 1
			if 0 <= j - 1 < w:
				if F[i][j - 1] == '#':
					cnt += 1
			if 0 <= j + 1 < w:
				if F[i][j + 1] == '#':
					cnt += 1
			if cnt == 0:
				print('No')
				return
print('Yes')


(h, w) = map(int, input().split())
l = ['.' * (w + 2)]
for i in range(h):
	l += ['.' + input() + '.']
l += ['.' * (w + 2)]
ans = 0
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if l[i][j] == '.':
			continue
		if l[i + 1][j] == '#' or l[i - 1][j] == '#' or l[i][j + 1] == '#' or (l[i][j - 1] == '#'):
			continue
		ans = 1
print('YNeos'[ans::2])


import sys
(h, w) = map(int, input().split())
a = ['.' * (w + 2)] + ['.' + input() + '.' for i in range(h)] + ['.' * (w + 2)]
for i in range(h):
	for (j, q) in enumerate(a[i + 1]):
		if q == '#':
			if a[i][j] != '#' and a[i + 1][j - 1] != '#' and (a[i + 1][j + 1] != '#') and (a[i + 2][j] != '#'):
				print('No')
				sys.exit()
print('Yes')


(h, w) = map(int, input().split())
s = ['.' * (w + 2)]
for i in range(h):
	s.append('.' + input() + '.')
s += ['.' * (w + 2)]
for i in range(h):
	for j in range(w):
		if s[i + 1][j + 1] == '#':
			if (s[i][j + 1] + s[i + 1][j] + s[i + 1][j + 2] + s[i + 2][j + 1]).count('.') == 4:
				print('No')
				quit()
print('Yes')


(h, w) = map(int, input().split())
a = ['.' * (w + 2)] + ['.' + input() + '.' for _ in range(h)] + ['.' * (w + 2)]
for i in range(h):
	for j in range(w):
		if a[i][j] == '#':
			if not (a[i + 1][j] == '#' or a[i - 1][j] == '#' or a[i][j + 1] == '#' or (a[i][j - 1] == '#')):
				print('No')
				exit()
print('Yes')


(H, W) = map(int, input().split())
Map = []
for i in range(H):
	Map.append(input())
for i in range(H):
	for j in range(W):
		if Map[i][j] == '#':
			if i - 1 >= 0 and i + 1 < H and (j - 1 >= 0) and (j + 1 < W):
				if Map[i - 1][j] != '#' and Map[i + 1][j] != '#' and (Map[i][j - 1] != '#') and (Map[i][j + 1] != '#'):
					print('No')
					exit()
print('Yes')


(h, w) = map(int, input().split())
L = ['b' * (w + 2)] + ['b' + input() + 'b' for i in range(h)] + ['b' * (w + 2)]
ans = 'ahe'
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if L[i][j] == '#' and (L[i + 1][j] != '#' and L[i - 1][j] != '#' and (L[i][j + 1] != '#') and (L[i][j - 1] != '#')):
			ans = 'No'
if ans != 'No':
	ans = 'Yes'
print(ans)


(h, w) = map(int, input().split())
d = [['.'] * (w + 2) for j in range(h + 2)]
for hh in range(h):
	moji = input()
	for ww in range(w):
		d[hh + 1][ww + 1] = moji[ww]
for k in range(1, h + 1):
	for l in range(1, w + 1):
		if d[k][l] == '#' and all((aa == '.' for aa in [d[k - 1][l], d[k + 1][l], d[k][l - 1], d[k][l + 1]])):
			print('No')
			exit()
print('Yes')


(h, w) = map(int, input().split())
S = ['.' + input() + '.' for i in range(h)]
S = ['.' * (w + 2)] + S + ['.' * (w + 2)]
r = 'Yes'
for i in range(h):
	for j in range(w):
		if S[i][j] == '#':
			if S[i - 1][j] == '.' and S[i + 1][j] == '.' and (S[i][j - 1] == '.') and (S[i][j + 1] == '.'):
				r = 'No'
				break
print(r)


(H, W) = map(int, input().split())
flag = True
field = [input() for i in range(H)]
for i in range(H):
	for j in range(W):
		if field[i][j] == '#':
			tmp = False
			if i - 1 >= 0 and field[i - 1][j] == '#':
				tmp = True
			if i + 1 < H and field[i + 1][j] == '#':
				tmp = True
			if j - 1 >= 0 and field[i][j - 1] == '#':
				tmp = True
			if j + 1 < W and field[i][j + 1] == '#':
				tmp = True
			if tmp == False:
				flag = False
if flag:
	print('Yes')
else:
	print('No')


(h, w) = map(int, input().split())
t = [['.'] * (w + 2)] + [['.'] + list(input()) + ['.'] for _ in range(h)] + [['.'] * (w + 2)]
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if t[i][j] == '.':
			continue
		if t[i - 1][j] == '.' and t[i + 1][j] == '.' and (t[i][j - 1] == '.') and (t[i][j + 1] == '.'):
			print('No')
			exit()
print('Yes')


(H, W) = list(map(int, input().split()))
S = [list(input()) for _ in range(H)]
for h in range(H):
	for w in range(W):
		if S[h][w] == '.':
			continue
		if h != 0 and S[h - 1][w] == '#':
			continue
		elif h != H - 1 and S[h + 1][w] == '#':
			continue
		elif w != 0 and S[h][w - 1] == '#':
			continue
		elif w != W - 1 and S[h][w + 1] == '#':
			continue
		print('No')
		return
print('Yes')


(h, w) = map(int, input().split())
s = [['.'] * (w + 2)]
for i in range(h):
	tmp = list(input())
	tmp.insert(0, '.')
	tmp.append('.')
	s.append(tmp)
ans = 'Yes'
for i in range(1, h):
	for j in range(1, w):
		if s[i][j] == '#' and s[i][j + 1] != '#' and (s[i + 1][j] != '#') and (s[i][j - 1] != '#') and (s[i - 1][j] != '#'):
			ans = 'No'
print(ans)


(h, w) = list(map(int, input().split()))
s = [input() for _ in range(h)]
for i in range(h):
	for j in range(w):
		if s[i][j] == '.':
			continue
		ok = False
		for (dx, dy) in [(1, 0), (0, 1), (0, -1), (-1, 0)]:
			nx = j + dx
			ny = i + dy
			if 0 <= nx < w and 0 <= ny < h and (s[ny][nx] == '#'):
				ok = True
		if not ok:
			print('No')
			return
print('Yes')


(H, W) = map(int, input().split())
field = []
for h in range(H):
	field.append(list(input()))
dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]
ans = 'Yes'
for h in range(H):
	for w in range(W):
		if field[h][w] != '#':
			continue
		ok = False
		for i in range(4):
			nw = dx[i] + w
			nh = dy[i] + h
			if nw < 0 or W <= nw or nh < 0 or (H <= nh):
				continue
			if field[nh][nw] == '#':
				ok = True
		if not ok:
			ans = 'No'
print(ans)


(H, W) = map(int, input().split())
s = [['.'] * (W + 2) for _ in range(H + 1)]
for i in range(H):
	s[1 + i][1:1 + W] = input()
ans = 'Yes'
for i in range(1, H):
	for j in range(1, W):
		if s[i][j] != '#':
			continue
		if s[i - 1][j] == '.' and s[i + 1][j] == '.' and (s[i][j - 1] == '.') and (s[i][j + 1] == '.'):
			ans = 'No'
print(ans)


(h, w) = map(int, input().split())
lis = []
for _ in range(h):
	lis.append(input())
for i in range(h):
	for j in range(w):
		if lis[i][j] == '#':
			if (i == 0 or lis[i - 1][j] == '.') and (j == 0 or lis[i][j - 1] == '.') and (i == h - 1 or lis[i + 1][j] == '.') and (j == w - 1 or lis[i][j + 1] == '.'):
				print('No')
				quit()
print('Yes')


(H, W) = map(int, input().split())
canvas = []
for i in range(H):
	canvas.append(list(input()))
for i in range(H):
	for j in range(W):
		cnt = 0
		if canvas[i][j] == '#':
			for h in range(-1, 2):
				for w in range(-1, 2):
					if canvas[min(max(i + h, 0), H - 1)][min(max(j + w, 0), W - 1)] == '#' and (abs(h) + abs(w)) % 2 == 1:
						cnt += 1
			if cnt == 0:
				print('No')
				return
print('Yes')


(N, M) = map(int, input().split())
c = 0
l = []
for i in range(N):
	l.append(list(input()))
N -= 1
M -= 1
for i in range(N):
	for j in range(M):
		if l[i][j] == '.':
			pass
		else:
			if i - 1 >= 0 and i + 1 <= N and (j - 1 >= 0) and (j + 1 <= M) and (l[i - 1][j] == '.') and (l[i + 1][j] == '.') and (l[i][j - 1] == '.') and (l[i][j + 1] == '.'):
				c += 1
			if i == 0 and j - 1 >= 0 and (j + 1 <= M) and (l[i + 1][j] == '.') and (l[i][j - 1] == '.') and (l[i][j + 1] == '.'):
				c += 1
			if i - 1 >= 0 and i + 1 <= N and (j == 0) and (l[i - 1][j] == '.') and (l[i + 1][j] == '.') and (l[i][j + 1] == '.'):
				c += 1
			if i == N and j - 1 >= 0 and (j + 1 <= M) and (l[i - 1][j] == '.') and (l[i][j - 1] == '.') and (l[i][j + 1] == '.'):
				c += 1
			if i - 1 >= 0 and i + 1 <= N and (j - 1 >= 0) and (j == M) and (l[i - 1][j] == '.') and (l[i + 1][j] == '.') and (l[i][j - 1] == '.'):
				c += 1
			if i == 0 and j == 0 and (l[i + 1][j] == '.') and (l[i][j + 1] == '.'):
				c += 1
			if i == 0 and j == M and (l[i + 1][j] == '.') and (l[i][j - 1] == '.'):
				c += 1
			if i == N and j == 0 and (l[i - 1][j] == '.') and (l[i][j + 1] == '.'):
				c += 1
			if i == N and j == M and (l[i - 1][j] == '.') and (l[i][j - 1] == '.'):
				c += 1
if c == 0:
	print('Yes')
else:
	print('No')


(H, W) = map(int, input().split())
s = ['.' + input() + '.' for _ in range(H)]
s.insert(0, '.' * (W + 2))
s.append('.' * (W + 2))
for i in range(1, H + 1):
	for j in range(1, W + 1):
		if s[i][j] == '#' and (s[i - 1][j] + s[i][j - 1:j + 2] + s[i + 1][j]).count('#') == 1:
			print('No')
			exit()
print('Yes')


(H, W) = map(int, input().split())
hw = ['.' * (W + 2)]
for i in range(H):
	hw.append('.' + input() + '.')
hw.append('.' * (W + 2))
ans = 'Yes'
for i in range(1, H + 1):
	for j in range(1, W + 1):
		if hw[i][j] == '#':
			if hw[i - 1][j] == '.' and hw[i][j - 1] == '.' and (hw[i][j + 1] == '.') and (hw[i + 1][j] == '.'):
				ans = 'No'
print(ans)


(H, W) = map(int, input().split())
grid = [input() for _ in range(H)]
flg = True
for i in range(H):
	for j in range(W):
		if grid[i][j] == '.':
			continue
		flg2 = False
		if j > 0 and grid[i][j - 1] == '#':
			flg2 = True
		if j < W - 1 and grid[i][j + 1] == '#':
			flg2 = True
		if i > 0 and grid[i - 1][j] == '#':
			flg2 = True
		if i < H - 1 and grid[i + 1][j] == '#':
			flg2 = True
		if not flg2:
			flg = False
print(['No', 'Yes'][flg])


(h, w) = map(int, input().split())
g = [input() for _ in range(h)]
for x in range(h):
	for y in range(w):
		if g[x][y] == '.':
			continue
		ok = 0
		for (dx, dy) in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
			(nx, ny) = (x + dx, y + dy)
			if 0 <= nx < h and 0 <= ny < w:
				if g[nx][ny] == '#':
					ok = 1
		if ok < 1:
			print('No')
			exit()
print('Yes')


(h, w) = map(int, input().split())
count = 0
S = ['.'] * (w + 2)
T = [list(input()) for i in range(h)]
for i in range(h):
	T[i].insert(0, '.')
	T[i].append('.')
T.insert(0, S)
T.append(S)
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if T[i][j] == '#' and T[i - 1][j] == T[i][j - 1] == T[i + 1][j] == T[i][j + 1] == '.':
			count += 1
print('Yes' if count == 0 else 'No')


import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque, Counter
from decimal import Decimal
import functools

def v():
	return input()

def k():
	return int(input())

def S():
	return input().split()

def I():
	return list(map(int, input().split()))

def X():
	return list(input())

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 ** 6)
mod = 10 ** 9 + 7
cnt = 0
ans = 0
inf = float('inf')
al = 'abcdefghijklmnopqrstuvwxyz'
AL = al.upper()
(H, W) = I()
pad_s = ['.' * (W + 2)]
for h in range(H):
	pad_s.append('.' + input() + '.')
pad_s.append('.' * (W + 2))
for (i, ss) in enumerate(pad_s):
	for (j, s) in enumerate(ss):
		if s == '#' and pad_s[i][j + 1] == '.' and (pad_s[i][j - 1] == '.') and (pad_s[i + 1][j] == '.') and (pad_s[i - 1][j] == '.'):
			print('No')
			return
print('Yes')


(H, W) = map(int, input().split())
S = ['.' + input() + '.' for i in range(H)]
S.append('.' * (W + 2))
S.insert(0, '.' * (W + 2))
F = 1
for i in range(H + 2):
	for j in range(W + 2):
		if S[i][j] == '#' and S[i + 1][j] == S[i - 1][j] == S[i][j + 1] == S[i][j - 1] == '.':
			F = 0
			break
print(['No', 'Yes'][F])


(h, w) = map(int, input().split())
s = list()
t = list()
a = [0 for i in range(w + 2)]
s.append(a)
for i in range(h):
	b = str(input())
	c = list(('0' + b + '0').replace('.', '0').replace('#', '1'))
	d = list(map(int, c))
	s.append(d)
	t.append(b)
s.append(a)
flag = 0
for j in range(1, h + 1):
	for k in range(1, w + 1):
		if flag == 1:
			break
		if s[j][k] == 1:
			cnt = 0
			cnt = s[j - 1][k] + s[j][k - 1] + s[j][k + 1] + s[j + 1][k]
			if cnt == 0:
				flag = 1
				print('No')
if flag == 0:
	print('Yes')


(H, W) = list(map(int, input().split()))
S = ['.' * (W + 2)]
for _ in range(H):
	S.append('.' + input() + '.')
S.append('.' * (W + 2))
for h in range(1, H + 1):
	for w in range(1, W + 1):
		if S[h][w] == '#':
			if '#' not in [S[h - 1][w], S[h][w - 1], S[h][w + 1], S[h + 1][w]]:
				print('No')
				exit()
print('Yes')


(H, W) = [int(i) for i in input().split()]
SS = [input() for _ in range(H)]

def get(lst, i, default=None):
	try:
		return lst[i]
	except IndexError:
		return default
for i in range(H):
	for j in range(W):
		s = SS[i][j]
		if s == '#':
			if '#' not in [get(get(SS, i - 1, []), j), get(get(SS, i, []), j - 1), get(get(SS, i + 1, []), j), get(get(SS, i, []), j + 1)]:
				print('No')
				import sys
				return
print('Yes')


(H, W) = map(int, input().split())
s_list = [input() for _ in range(H)]
ans = 'Yes'
for i in range(1, H - 1):
	for j in range(1, W - 1):
		if s_list[i][j] == '#' and s_list[i - 1][j] == s_list[i + 1][j] == s_list[i][j - 1] == s_list[i][j + 1] == '.':
			ans = 'No'
			break
print(ans)


(h, w) = map(int, input().split())
s = []
for i in range(h):
	s.append('.' + input() + '.')
s = ['.' * (w + 2)] + s + ['.' * (w + 2)]
ans = 'Yes'
for i in range(1, h):
	for j in range(1, w):
		if s[i][j] == '#':
			u = s[i - 1][j]
			d = s[i + 1][j]
			l = s[i][j - 1]
			r = s[i][j + 1]
			if u == '.' and d == '.' and (l == '.') and (r == '.'):
				ans = 'No'
print(ans)


import sys
(H, W) = map(int, input().split())
s = [input() + '.' for _ in range(H)]
s.append('.' * W)
d = ((0, 1), (1, 0), (0, -1), (-1, 0))
for h in range(H):
	for w in range(W):
		if s[h][w] == '#':
			if all([s[h + dh][w + dw] == '.' for (dh, dw) in d]):
				print('No')
				sys.exit()
print('Yes')


(H, W) = map(int, input().split())
S = ['a' * (W + 2)] + [list('a' + input() + 'a') for i in range(H)] + ['a' * (W + 2)]
for i in range(H):
	for j in range(W):
		if S[i + 1][j + 1] == '#':
			if [S[i][j + 1], S[i + 1][j], S[i + 1][j + 2], S[i + 2][j + 1]].count('#') < 1:
				print('No')
				exit()
print('Yes')


(h, w) = map(int, input().split())
s = ['.' * (w + 2)] + ['.' + input() + '.' for _ in range(h)] + ['.' * (w + 2)]
for i in range(1, h + 2):
	for j in range(1, w + 2):
		if s[i][j] == '#':
			if '#' not in (s[i - 1][j], s[i + 1][j], s[i][j - 1], s[i][j + 1]):
				print('No')
				exit()
			else:
				pass
		else:
			pass
print('Yes')


(h, w) = list(map(int, input().split()))
s = ['.' + input() + '.' for _ in range(h)]
s = ['.' * (w + 2)] + s + ['.' * (w + 2)]
for y in range(1, h + 1):
	for x in range(1, w + 1):
		if s[y][x] == '.':
			continue
		ok = False
		for (dy, dx) in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
			if s[y + dy][x + dx] == '#':
				ok = True
		if not ok:
			print('No')
			return
print('Yes')


import sys
(h, w) = map(int, input().split())
s = [list(input()) for i in range(h)]
for i in range(h):
	for j in range(w):
		if s[i][j] == '#' and (i == 0 or s[i - 1][j] == '.') and (i == h - 1 or s[i + 1][j] == '.') and (j == 0 or s[i][j - 1] == '.') and (j == w - 1 or s[i][j + 1] == '.'):
			print('No')
			sys.exit()
print('Yes')


(N, M) = map(int, input().split())
p = [input() for i in range(N)]
ans = 'Yes'
for n in range(1, N - 1):
	for m in range(1, M - 1):
		if p[n][m] == '#':
			if p[n - 1][m] != '#' and p[n][m - 1] != '#' and (p[n + 1][m] != '#') and (p[n][m + 1] != '#'):
				ans = 'No'
				break
print(ans)


(H, W) = map(int, input().split())
S = [['.'] * (W + 2)]
for i in range(H):
	S.append('.' + input() + '.')
S.append('.' * (W + 2))
for i in range(H):
	for j in range(W):
		if S[i][j] == '#':
			if S[i - 1][j] == '.' and S[i + 1][j] == '.' and (S[i][j - 1] == '.') and (S[i][j + 1] == '.'):
				print('No')
				exit()
print('Yes')


(H, W) = map(int, input().split())
s = []
for _ in range(H):
	s.append(input())
Flg = 'Yes'
for i in range(H):
	for j in range(W):
		if s[i][j] == '#':
			if s[i][max(j - 1, 0)] == '.' and s[i][min(j + 1, W - 1)] == '.' and (s[min(i + 1, H - 1)][j] == '.') and (s[max(i - 1, 0)][j] == '.'):
				Flg = 'No'
print(Flg)


import sys
sys.setrecursionlimit(10 ** 8)
ini = lambda : int(sys.stdin.readline())
inl = lambda : [int(x) for x in sys.stdin.readline().split()]
ins = lambda : sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print('\x1b[33m', *a, '\x1b[0m', **dict(file=sys.stderr, **kw))

def solve():
	(h, w) = inl()
	grid = [None] * h
	for i in range(h):
		grid[i] = ins()
	dx = [0, 0, 1, -1]
	dy = [1, -1, 0, 0]
	for i in range(h):
		for j in range(w):
			if grid[i][j] != '#':
				continue
			ok = False
			for k in range(4):
				i2 = i + dy[k]
				j2 = j + dx[k]
				if 0 <= i2 < h and 0 <= j2 < w and (grid[i2][j2] == '#'):
					ok = True
					break
			if not ok:
				return False
	return True
print('Yes' if solve() else 'No')


(h, w) = (int(i) for i in input().split())
s = ['.' + input() + '.' for i in range(h)]
(s, flag) = (['.' * (w + 2)] + s + ['.' * (w + 2)], True)
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if s[i][j] == '#':
			if s[i - 1][j] == '.' and s[i + 1][j] == '.' and (s[i][j - 1] == '.') and (s[i][j + 1] == '.'):
				flag = False
if flag:
	print('Yes')
else:
	print('No')


(h, w) = (int(i) for i in input().split())
s = [input() for i in range(h)]
for i in range(h):
	for j in range(w):
		if s[i][j] == '#':
			if i == 0 or s[i - 1][j] == '.':
				if i == h - 1 or s[i + 1][j] == '.':
					if j == 0 or s[i][j - 1] == '.':
						if j == w - 1 or s[i][j + 1] == '.':
							print('No')
							exit()
print('Yes')


(H, W) = map(int, input().split())
s_list = [input() for i in range(H)]
flag = True
for i in range(1, H - 1):
	for j in range(1, W - 1):
		if s_list[i][j] == '#':
			if s_list[i - 1][j] == '.' and s_list[i + 1][j] == '.' and (s_list[i][j - 1] == '.') and (s_list[i][j + 1] == '.'):
				flag = False
				break
if flag:
	print('Yes')
else:
	print('No')


(h, w) = map(int, input().split())
area = [input() for i in range(h)]
xy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
for i in range(h):
	for j in range(w):
		if area[i][j] == '#':
			f = 0
			for (x, y) in xy:
				if 0 <= i + y < h and 0 <= j + x < w and (area[i + y][j + x] == '#'):
					f = 1
			if f == 0:
				print('No')
				exit()
print('Yes')


(H, W) = map(int, input().split())
S = [input() for i in range(H)]
for i in range(H):
	for j in range(W):
		if S[i][j] == '#':
			bk = sum([t[j].count('#') for t in S[max(0, i - 1):min(H, i + 2)]])
			bk += S[i][max(0, j - 1):min(W, j + 2)].count('#') - 1
			if bk == 1:
				print('No')
				exit()
print('Yes')


(h, w) = map(int, input().split())
S = []
for i in range(h):
	S.append(list(input()))
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
for i in range(1, h - 1):
	for j in range(1, w - 1):
		if S[i][j] == '#':
			if all((S[i + dx[k]][j + dy[k]] == '.' for k in range(4))):
				print('No')
				exit()
print('Yes')


import os
import sys
import numpy as np

def dfs(visited, maze, h, w):
	visited[h, w] = -1
	if maze[h, w + 1] == 1 and visited[h, w + 1] == 1:
		dfs(visited, maze, h, w + 1)
	if maze[h, w - 1] == 1 and visited[h, w - 1] == 1:
		dfs(visited, maze, h, w - 1)
	if maze[h + 1, w] == 1 and visited[h + 1, w] == 1:
		dfs(visited, maze, h + 1, w)
	if maze[h - 1, w] == 1 and visited[h - 1, w] == 1:
		dfs(visited, maze, h - 1, w)

def check_maze(maze, h, w):
	if maze[h, w + 1] == 1:
		return 1
	elif maze[h, w - 1] == 1:
		return 1
	elif maze[h + 1, w] == 1:
		return 1
	elif maze[h - 1, w] == 1:
		return 1
	else:
		return 0

def main():
	(H, W) = list(map(int, input().split()))
	maze = []
	for _ in range(H):
		S = input()
		S = [1 if s == '#' else 0 for s in S]
		maze.append(S)
	maze = np.array(maze)
	maze = np.pad(maze, [(1, 1), (1, 1)])
	visited = np.copy(maze)
	for h in range(1, H + 1):
		for w in range(1, W + 1):
			if maze[h, w] == 1:
				flag = check_maze(maze, h, w)
				if flag == 0:
					print('No')
					return
	print('Yes')

def __starting_point():
	main()
__starting_point()


(h, w) = map(int, input().split())
s = [list(map(lambda x: x == '#', list(input()))) for i in range(h)]
f = 0
for i in range(h):
	for j in range(w):
		if s[i][j]:
			s[i][j] ^= 1
			if 1 ^ (s[max(0, i - 1)][j] or s[i][max(0, j - 1)] or s[i][min(w - 1, j + 1)] or s[min(h - 1, i + 1)][j]):
				f = 1
			s[i][j] ^= 1
print('YNeos'[f::2])


(h, w) = map(int, input().split())
S = [['.'] * (w + 2)] + [['.'] + list(input()) + ['.'] for _ in range(h)] + [['.'] * (w + 2)]
ans = 'Yes'
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if S[i][j] == '#' and S[i + 1][j] == '.' and (S[i - 1][j] == '.') and (S[i][j + 1] == '.') and (S[i][j - 1] == '.'):
			ans = 'No'
			break
print(ans)


(H, W) = map(int, input().split())
x = [list(map(str, list(input()))) for l in range(H)]
for i in range(len(x)):
	x[i].insert(0, '.')
	x[i].append('.')
x.insert(0, ['.'] * (W + 2))
x.append(['.'] * (W + 2))
for i in range(1, H + 1):
	for j in range(1, W + 1):
		if x[i][j] == '#':
			if x[i][j - 1] == x[i][j + 1] == x[i - 1][j] == x[i + 1][j] == '.':
				print('No')
				return
print('Yes')


(H, W) = map(int, input().split())
S = [input() for i in range(H)]
dy = [0, 1, 0, -1]
dx = [1, 0, -1, 0]
for y in range(H):
	for x in range(W):
		if S[y][x] == '.':
			continue
		if any((0 <= y + dy[i] < H and 0 <= x + dx[i] < W and (S[y + dy[i]][x + dx[i]] == '#') for i in range(4))):
			continue
		print('No')
		exit()
print('Yes')


(H, W) = map(int, input().split())
hw = [['.'] * (W + 2)] + [['.'] + list(input()) + ['.'] for _ in range(H)] + [['.'] * (W + 2)]
ans = 'Yes'
h = 1
while h <= H:
	w = 1
	while w <= W:
		if hw[h][w] == '#':
			if all([hw[h - 1][w] == '.', hw[h + 1][w] == '.', hw[h][w - 1] == '.', hw[h][w + 1] == '.']):
				ans = 'No'
		w += 1
	h += 1
print(ans)


(h, w) = list(map(int, input().split()))
S = [input() for i in range(h)]
for (i, T) in enumerate(S):
	for (j, t) in enumerate(T):
		if t == '#':
			flag = 0
			if j > 0:
				if T[j - 1] == '#':
					flag += 1
			if j < w - 1:
				if T[j + 1] == '#':
					flag += 1
			if i > 0:
				if S[i - 1][j] == '#':
					flag += 1
			if i < h - 1:
				if S[i + 1][j] == '#':
					flag += 1
			if flag == 0:
				print('No')
				return
print('Yes')


(H, W) = map(int, input().split())
grid = []
ans = 'Yes'
for _ in range(H):
	grid_i = input().split()
	grid.append(grid_i[0])
for i in range(H):
	for j in range(W):
		if grid[i][j] == '#':
			X = 'NG'
			if i - 1 >= 0 and grid[i - 1][j] == '.' or i < 1:
				None
			else:
				X = 'OK'
			if j - 1 >= 0 and grid[i][j - 1] == '.' or j < 1:
				None
			else:
				X = 'OK'
			if i + 1 < H and grid[i + 1][j] == '.' or i + 1 >= H:
				None
			else:
				X = 'OK'
			if j + 1 < W and grid[i][j + 1] == '.' or j + 1 >= W:
				None
			else:
				X = 'OK'
			if X == 'NG':
				ans = 'No'
print(ans)


(H, W) = list(map(int, input().split()))
Grid = [['.'] * (W + 2)]
for i in range(H):
	Grid.append(list('.' + str(input()) + '.'))
Grid.append(['.'] * (W + 2))
for k in range(1, H + 1):
	for l in range(1, W + 1):
		moji = Grid[k][l]
		if moji == '#':
			flg = 0
			for (rec, col) in ((1, 0), (0, 1), (-1, 0), (0, -1)):
				if Grid[k + rec][l + col] == '#':
					Grid[k + rec][l + col] = 'b'
					flg = 1
				elif Grid[k + rec][l + col] == 'b':
					flg = 1
			if flg == 1:
				Grid[k][l] = 'b'
			else:
				break
	else:
		continue
	print('No')
	break
else:
	print('Yes')


import sys
(H, W) = map(int, input().split())
X = ['.' * (W + 2)]
for _ in range(H):
	X.append('.' + input().strip() + '.')
X += ['.' * (W + 2)]
for i in range(1, H + 1):
	for j in range(1, W + 1):
		if X[i][j] == '#' and '#' not in [X[i + 1][j], X[i - 1][j], X[i][j - 1], X[i][j + 1]]:
			print('No')
			sys.exit()
print('Yes')


(h, w) = (int(i) for i in input().split())
s = ['.' * (w + 2)] + ['.' + input() + '.' for i in range(h)] + ['.' * (w + 2)]
for i in range(1, h - 1):
	for j in range(1, w - 1):
		if s[i][j] == '#':
			tonari = [s[i][j + 1], s[i][j - 1], s[i + 1][j], s[i - 1][j]]
			if not any((i == '#' for i in tonari)):
				print('No')
				exit()
print('Yes')


(h, w) = map(int, input().split())
s = []
for i in range(h):
	li = input()
	s.append(li)

def check(s, x, y, w, h):
	dx = [0, 0, -1, 1]
	dy = [1, -1, 0, 0]
	for i in range(4):
		(ny, nx) = (y + dy[i], x + dx[i])
		if 0 <= nx < w and 0 <= ny < h:
			if s[ny][nx] == '#':
				return True
	return False
ok = True
for i in range(h):
	for j in range(w):
		if s[i][j] == '#':
			ok = check(s, j, i, w, h)
			if not ok:
				break
	if not ok:
		break
if ok or (w == 1 and h == 1):
	print('Yes')
else:
	print('No')


(h, w) = map(int, input().split())
a = ['.' * (w + 2)]
s = ['.' + input() + '.' for _ in range(h)]
s = a + s + a
f = True
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if s[i][j] == '#' and s[i][j - 1] == '.' and (s[i][j + 1] == '.') and (s[i - 1][j] == '.') and (s[i + 1][j] == '.'):
			f = False
if f:
	print('Yes')
else:
	print('No')


(h, w) = [int(i) for i in input().split()]
s = [list(input()) for _ in range(h)]
flg = True
for i in range(1, h - 1):
	for j in range(1, w - 1):
		if s[i][j] == '#' and s[i - 1][j] == s[i + 1][j] == s[i][j - 1] == s[i][j + 1] == '.':
			flg = False
print('Yes' if flg else 'No')


(h, w) = map(int, input().split())
a = [0] * (h + 2)
a[0] = '.' * (w + 2)
a[h + 1] = a[0]
for _ in range(1, h + 1):
	j = input()
	a[_] = '.' + j + '.'
x = 'Yes'
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if a[i][j] == '#':
			if a[i - 1][j] == '.' and a[i + 1][j] == '.' and (a[i][j - 1] == '.') and (a[i][j + 1] == '.'):
				x = 'No'
				break
print(x)


(h, w) = map(int, input().split())
a = [0] * (w + 2)
m = [a]
ans = 'Yes'
for i in range(h):
	s = input()
	m.append([0] + [1 if x == '#' else 0 for x in s] + [0])
m.append(a)
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if m[i][j] == 1 and sum(m[i][j - 1:j + 2], m[i - 1][j] + m[i + 1][j]) == 1:
			ans = 'No'
print(ans)


(h, w) = list(map(int, input().split()))
s = [input() for _ in range(h)]
for i in range(h):
	for j in range(w):
		if s[i][j] == '#':
			flag = False
			for (i_new, j_new) in [(i + 1, j), (i - 1, j), (i, j + 1), (i, j - 1)]:
				if i_new < 0 or i_new >= h or j_new < 0 or (j_new >= w):
					continue
				if s[i_new][j_new] == '#':
					flag = True
					break
			if not flag:
				print('No')
				return
print('Yes')


(h, w) = map(int, input().split())
l = [input() for _ in range(h)]
dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]
for i in range(h):
	for j in range(w):
		if l[i][j] == '#':
			cnt = 0
			for di in range(4):
				y = i + dx[di]
				x = j + dy[di]
				if x < 0 or y < 0 or x > w - 1 or (y > h - 1):
					continue
				elif l[y][x] == '#':
					cnt += 1
			if cnt == 0:
				print('No')
				return
print('Yes')


def mapt(fn, *args):
	return tuple(map(fn, *args))

def Input():
	return mapt(int, input().split(' '))

def check(i, j, data):
	return any((data[x][y] == '#' for (x, y) in ((i - 1, j), (i + 1, j), (i, j - 1), (i, j + 1))))

def main():
	(h, w) = Input()
	a = ['-' * (w + 2)]
	data = a + ['-' + input() + '-' for _ in range(h)] + a
	ans = True
	for i in range(1, h + 1):
		for j in range(1, w + 1):
			if data[i][j] == '#':
				if not check(i, j, data):
					ans = False
	if ans:
		print('Yes')
	else:
		print('No')
main()


(H, W) = map(int, input().split())
G = ['.' * (W + 2)]
for k in range(H):
	G.append('.' + input() + '.')
G.append('.' * (W + 2))
for k in range(1, H + 1):
	for l in range(1, W + 1):
		if G[k][l] == '#':
			if G[k + 1][l] == '.' and G[k - 1][l] == '.' and (G[k][l - 1] == '.') and (G[k][l + 1] == '.'):
				print('No')
				exit(0)
print('Yes')


import sys
(H, W) = list(map(int, input().split()))
S = [list(sys.stdin.readline().strip()) for _ in range(H)]
dx = [1, 0, -1, 0]
dy = [0, -1, 0, 1]
for (i, row) in enumerate(S):
	for (j, s) in enumerate(row):
		if s == '.':
			continue
		ok = False
		for k in range(4):
			nx = j + dx[k]
			ny = i + dy[k]
			if not (0 <= nx < W and 0 <= ny < H):
				continue
			if S[ny][nx] == '#':
				ok = True
		if ok is False:
			print('No')
			return
print('Yes')


(H, W) = map(int, input().split())
cam = [input() for i in range(H)]
ans = 'Yes'
for i in range(1, H - 1):
	for j in range(1, W - 1):
		if cam[i][j] == '#':
			if cam[i - 1][j] == cam[i + 1][j] == cam[i][j - 1] == cam[i][j + 1] == '.':
				ans = 'No'
				break
print(ans)


(h, w) = map(int, input().split())
src = [input() for i in range(h)]
ans = []
for row in src:
	ans.append(list(row))
dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
for x in range(h):
	for y in range(w):
		if src[x][y] == '.':
			continue
		if src[x][y] == '#':
			flag = 0
			for (dx, dy) in dxy:
				if x + dx < 0 or x + dx > h - 1 or y + dy < 0 or (y + dy > w - 1):
					continue
				if src[x + dx][y + dy] == '#':
					flag = 1
					break
			if flag == 0:
				print('No')
				return
print('Yes')


(H, W) = map(int, input().split())
S = [['.'] * (W + 2)]
for i in range(H):
	S.append(list('.' + input().rstrip() + '.'))
S.append(['.'] * (W + 2))

def checkaround(i, j):
	dirc = [[0, 1], [-1, 0], [0, -1], [1, 0]]
	for d in dirc:
		if S[i - d[0]][j - d[1]] == '#':
			return True
	return False

def main():
	for i in range(1, H + 1):
		for j in range(1, W + 1):
			if S[i][j] == '#':
				if not checkaround(i, j):
					print('No')
					return
	print('Yes')
main()


(h, w) = map(int, input().split())
c = []
c.append('.' * (w + 2))
for i in range(h):
	c.append('.{}.'.format(input()))
c.append('.' * (w + 2))
for i in range(1, h + 1):
	for j in range(1, w + 1):
		if c[i][j] == '#' and c[i - 1][j] == c[i][j - 1] == c[i + 1][j] == c[i][j + 1] == '.':
			print('No')
			exit()
print('Yes')


(H, W) = map(int, input().split())
S = [input() for _ in range(H)]
for i in range(H):
	for j in range(W):
		if S[i][j] == '#':
			for (ni, nj) in ((i + 1, j), (i - 1, j), (i, j + 1), (i, j - 1)):
				if 0 <= ni < H and 0 <= nj < W and (S[ni][nj] == '#'):
					break
			else:
				print('No')
				exit()
print('Yes')


(H, W) = map(int, input().split())
S = [list(input()) for i in range(H)]
for h in range(H):
	for w in range(W):
		if S[h][w] in ['.', 'B']:
			continue
		ary = [[0, 1], [0, -1], [1, 0], [-1, 0]]
		flag = False
		for (x, y) in ary:
			xd = h + x
			yd = w + y
			if xd < 0 or xd >= H or yd < 0 or (yd >= W):
				continue
			if S[xd][yd] in ['B', '#']:
				S[h][w] = 'B'
				S[xd][yd] = 'B'
				flag = True
		if not flag:
			print('No')
			return
print('Yes')


(H, W) = map(int, input().split())
graph = []
for _ in range(H):
	graph.append(list(input()))
res = True
for j in range(1, W - 1):
	for i in range(1, H - 1):
		if graph[i][j] == '#' and graph[i + 1][j] == '.' and (graph[i - 1][j] == '.') and (graph[i][j + 1] == '.') and (graph[i][j - 1] == '.'):
			print('No')
			exit()
print('Yes')


(h, w) = map(int, input().split())
original = [list(input()) for _ in range(h)]
for i in range(h - 1):
	for j in range(w - 1):
		if original[i][j] == '#' and original[i - 1][j] != '#' and (original[i + 1][j] != '#') and (original[i][j - 1] != '#') and (original[i][j + 1] != '#'):
			print('No')
			exit()
print('Yes')


(H, W) = map(int, input().split())
matrix = []
for i in range(H):
	matrix.append(list(input()))
for h in range(1, H - 1):
	for w in range(1, W - 1):
		if matrix[h][w] == '#':
			if matrix[h - 1][w] == '.' and matrix[h][w - 1] == '.' and (matrix[h + 1][w] == '.') and (matrix[h][w + 1] == '.'):
				print('No')
				exit()
print('Yes')


(H, W) = map(int, input().split())
List = [list(input()) for i in range(H)]
res = 'Yes'
flag = True

def checkAround(ListX, i, j):
	if i == 0 and j == 0:
		if List[i + 1][j] == '#' or List[i][j + 1] == '#':
			return True
		else:
			return False
	elif i == 0 and j != 0 and (j != W - 1):
		if List[i + 1][j] == '#' or List[i][j - 1] == '#' or List[i][j + 1] == '#':
			return True
		else:
			return False
	elif i == 0 and j == W - 1:
		if List[i + 1][j] == '#' or List[i][j - 1] == '#':
			return True
		else:
			return False
	elif i != 0 and i != H - 1 and (j == 0):
		if List[i + 1][j] == '#' or List[i - 1][j] == '#' or List[i][j + 1] == '#':
			return True
		else:
			return False
	elif i == H - 1 and j == W - 1:
		if List[i - 1][j] == '#' or List[i][j - 1] == '#':
			return True
		else:
			return False
	elif i == H - 1 and j != 0 and (j != W - 1):
		if List[i - 1][j] == '#' or List[i][j + 1] == '#' or List[i][j - 1] == '#':
			return True
		else:
			return False
	elif i == H - 1 and j == 0:
		if List[i - 1][j] == '#' or List[i][j - 1] == '#':
			return True
		else:
			return False
	elif i != 0 and i != H - 1 and (j == W - 1):
		if List[i + 1][j] == '#' or List[i - 1][j] == '#' or List[i][j - 1] == '#':
			return True
		else:
			return False
	elif List[i + 1][j] == '#' or List[i - 1][j] == '#' or List[i][j - 1] == '#' or (List[i][j + 1] == '#'):
		return True
	else:
		return False
for k in range(H):
	for l in range(W):
		if List[k][l] == '.':
			pass
		else:
			flag = checkAround(List, k, l)
			if not flag:
				res = 'No'
				break
	if not flag:
		break
print(res)


(H, W) = map(int, input().split())
G = [list('.' * (W + 2)) for _ in range(H + 2)]
for i in range(H):
	G[i + 1][1:W + 1] = input()
ans = 'Yes'
for i in range(1, H):
	for j in range(1, W):
		if G[i][j] == '#':
			if G[i - 1][j] == '.' and G[i + 1][j] == '.' and (G[i][j - 1] == '.') and (G[i][j + 1] == '.'):
				ans = 'No'
				break
print(ans)


(h, w) = list(map(int, input().split()))
masu = []
masu.append([])
for i in range(w + 2):
	masu[0].append('.')
for i in range(h):
	masu.append([])
	masu[i + 1].append('.')
	yoko = input()
	for j in range(w):
		masu[i + 1].append(yoko[j])
for i in range(w + 2):
	masu[0].append('.')
for i in range(1, h - 1):
	for j in range(1, w - 1):
		if masu[i][j] == '#':
			if masu[i][j + 1] == '.' and masu[i][j - 1] == '.' and (masu[i + 1][j] == '.') and (masu[i - 1][j] == '.'):
				print('No')
				return
print('Yes')


(h, w) = map(int, input().split())
b = '.'
j = [b + b * w + b]
s = j + [b + input() + b for _ in [0] * h] + j
for i in range(1, h + 1):
	d = [n + 1 for n in range(w) if s[i][n:n + 3] == '.#.']
	if d and any([s[i - 1][c] == s[i + 1][c] == b for c in d]):
		print('No')
		exit()
print('Yes')


(H, W) = map(int, input().split())
g = ['.' + input() + '.' for _ in range(H)]
g = ['.' * (W + 2)] + g + ['.' * (W + 2)]
for i in range(1, H + 1):
	for j in range(1, W + 1):
		if g[i][j] == '#' and g[i - 1][j] == '.' and (g[i][j + 1] == '.') and (g[i + 1][j] == '.') and (g[i][j - 1] == '.'):
			print('No')
			exit()
print('Yes')


(H, W) = map(int, input().split())
C = ['.' * (W + 2)] + ['.' + input() + '.' for _ in [0] * H] + ['.' * (W + 2)]
for i in range(1, H + 1):
	for j in range(1, W + 1):
		if C[i][j] == '#' and '#' not in [C[i - 1][j], C[i][j - 1], C[i][j + 1], C[i + 1][j]]:
			print('No')
			exit()
print('Yes')


(h, w) = map(int, input().split())
a = ['.' * (w + 2)]
for i in range(h):
	x = input()
	a.append('.' + x + '.')
a.append('.' * (w + 2))
for i in range(h):
	for j in range(w):
		if a[i + 1][j + 1] == '#':
			if a[i][j + 1] == '#' or a[i + 2][j + 1] == '#' or a[i + 1][j + 2] == '#' or (a[i + 1][j] == '#'):
				continue
			else:
				print('No')
				exit()
print('Yes')


from sys import stdin, stdout

def solve():
	(h, w) = list(map(int, input().split()))
	grid = []
	for _ in range(h):
		s = input()
		assert len(s) == w
		grid.append(s)
	for i in range(h):
		for j in range(w):
			if grid[i][j] == '.':
				continue
			isolate = True
			for px in [i - 1, i + 1]:
				if px >= 0 and px < h:
					if grid[px][j] == '#':
						isolate = False
			for py in [j - 1, j + 1]:
				if py >= 0 and py < w:
					if grid[i][py] == '#':
						isolate = False
			if isolate:
				print('No')
				return
	print('Yes')

def main():
	solve()

def __starting_point():
	main()
__starting_point()


(H, W) = map(int, input().split())
S = [input() for _ in range(H)]
ans = 'Yes'
for i in range(H):
	for j in range(W):
		if S[i][j] == '#':
			if S[max(0, i - 1)][j] != '#' and S[min(i + 1, H - 1)][j] != '#' and (S[i][max(0, j - 1)] != '#') and (S[i][min(j + 1, W - 1)] != '#'):
				ans = 'No'
				break
print(ans)


(H, W) = map(int, input().split())
s = []
ans = 'Yes'
for _ in range(H):
	s.append(input())
for i in range(1, H - 1):
	for j in range(1, W - 1):
		if s[i][j] == '#' and s[i][j + 1] == s[i + 1][j] == s[i][j - 1] == s[i - 1][j] == '.':
			print('No')
			return
print(ans)


(h, w) = map(int, input().split())
L = [list(input()) for i in range(h)]
for i in range(h):
	for j in range(w):
		if L[i][j] == '#':
			if L[i][max(j - 1, 0)] != '#' and L[i][min(j + 1, w - 1)] != '#' and (L[max(i - 1, 0)][j] != '#') and (L[min(i + 1, h - 1)][j] != '#'):
				print('No')
				exit()
print('Yes')


(h, w) = list(map(int, input().split()))
s = [input() for _ in range(h)]
dh = [0, 1, 0, -1]
dw = [1, 0, -1, 0]
flag = 0
for i in range(h):
	for j in range(w):
		if s[i][j] == '#':
			cnt = 0
			for p in range(4):
				if i + dh[p] < 0 or i + dh[p] >= h or j + dw[p] < 0 or (j + dw[p] >= w):
					continue
				elif s[i + dh[p]][j + dw[p]] == '#':
					cnt += 1
			if cnt == 0:
				flag = 1
				break
		if flag == 1:
			break
	if flag == 1:
		print('No')
		break
else:
	print('Yes')


(H, W) = list(map(int, input().split()))
s = [input() for _ in range(H)]
cells = [(i, j) for i in range(H) for j in range(W)]
di = [1, 0, -1, 0]
dj = [0, 1, 0, -1]
for (i, j) in cells:
	if s[i][j] == '.':
		continue
	flag = False
	for k in range(4):
		ni = i + di[k]
		nj = j + dj[k]
		if ni < 0 or nj < 0 or ni >= H or (nj >= W):
			continue
		if s[ni][nj] == '#':
			flag = True
	if not flag:
		print('No')
		break
else:
	print('Yes')


(H, W) = map(int, input().split())
cambas = []
for i in range(H):
	cambas.append(input())
ans = 'Yes'
for i in range(1, H - 1):
	for j in range(1, W - 1):
		if cambas[i][j] == '#' and cambas[i][j + 1] == cambas[i + 1][j] == cambas[i - 1][j] == cambas[i][j - 1] == '.':
			ans = 'No'
			break
print(ans)