Problem:
 Score: 300 points    Problem Statement  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 1 3 3
.#.
###
.#.      Sample Output 1 Yes  One possible way to achieve the objective is shown in the figure below. Here, the squares being painted are marked by stars.        Sample Input 2 5 5
#.#.#
.#.#.
#.#.#
.#.#.
#.#.#      Sample Output 2 No  square1001 cannot achieve his objective here.       Sample Input 3 11 11
...#####...
.##.....##.
#..##.##..#
#..##.##..#
#.........#
#...###...#
.#########.
.#.#.#.#.#.
##.#.#.#.##
..##.#.##..
.##..#..##.      Sample Output 3 Yes

Solution (Python):
from collections import deque
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] == '
            A = False
            B = False
            C = False
            D = False
            if i != h-1 and s[i+1][j] == '
                A = True
            if i != 0 and s[i-1][j] == '
                B = True
            if j != w-1 and s[i][j+1] == '
                C = True
            if j != 0 and s[i][j-1] == '
                D = True
            if not A and not B and not C and not D:
                print('No')
                exit(0)
print('Yes')

Solution (Python):
h, w = map(int, input().split())

grid = []
grid.append(['.'] * (w + 2))
for _ in range(h):
    word = '.' + input() + '.'
    grid.append([i for i in word])
grid.append(['.'] * (w + 2))

for i in range(1, h):
    for j in range(1, w):
        if grid[i][j] == '
            if grid[i][j-1] == '
                pass
            else:
                print('No')
                exit()

print('Yes')

Solution (Python):
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] == "
      if S[i+1][j] != "
        print("No")
        exit()
print("Yes")

Solution (Python):
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] != "
          print("No")
          exit()
print("Yes")

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

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

Solution (Python):

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

S_array = [[0 for i in range(W+2)]]

for i in range(1,H+1):
    S = list(input())
    S_array.append([0]+S+[0])
    
S_array.append([0 for i in range(W+2)])

No_flag = 0


for i in range(1,H+1):
    for j in range(1,W+1):
        if S_array[i][j]=="
            print("No")
            No_flag = 1
            break
    if No_flag == 1:
        break
else:
    print("Yes")

Solution (Python):
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")

Solution (Python):
h, w = map(int, input().split())
L = ['.'*(w+1)]
for i in range(h):
  L.append('.'+input()+'.')
L.append('.'*(w+1))  

out = 1
for i in range(1, h+1):
  for j in range(1, w+1):
    if L[i][j] == '
      if L[i][j+1] == '
        out *= 1
      else:
        out *= 0

if out == 1:
  print('Yes')
else:
  print('No')

Solution (Python):
H , W = map(int,input().split())
stage = list(list(input()) for _ in range(H))

dx = [0,1,0,-1]
dy = [1,0,-1,0]
for i in range(H):
    for j in range(W):
        if stage[i][j] == ".":
            continue
        Flag = True
        for k in range(4):
            if 0 <= j + dx[k] < W and 0 <= i + dy[k] < H and stage[i + dy[k]][j + dx[k]] == "
                Flag = False
                break
        if Flag:
            print("No")
            exit()
print("Yes")

Solution (Python):
h,w=map(int,input().split())
li=[list(input()) for i in range(h)]
yoko=[[1,0],[-1,0],[0,1],[0,-1]]
import itertools
for i in range(h):
  for j in range(w):
    if li[i][j]=="
      flag=0
      for dx,dy in yoko:
        if h>i+dx>=0 and w>j+dy>=0:
          if li[i+dx][j+dy]=="
            flag+=1
      if flag==0:
        print("No")
        exit()
print("Yes")

Solution (Python):
h,w=map(int,input().split())
li=[list(input()) for i in range(h)]
yoko=[[1,0],[-1,0],[0,1],[0,-1]]
import itertools
for i in range(h):
  for j in range(w):
    if li[i][j]=="
      flag=0
      for za in yoko:
        dx=za[0]
        dy=za[1]
        if h>i+dx>=0 and w>j+dy>=0:
          if li[i+dx][j+dy]=="
            flag+=1
      if flag==0:
        print("No")
        exit()
print("Yes")

Solution (Python):
H, W = map(int, input().split())
Grid = [input() for _ in range(H)]

d = [(1,0),(-1,0),(0,1),(0,-1)]
ans = True

for i in range(H):
    for j in range(W):
        if Grid[i][j] == '
            count = 0
            for dx, dy in d:
                if 0 <= i + dy and i + dy <= H-1 and 0 <= j + dx and j + dx <= W-1:
                    if Grid[i+dy][j+dx] == '
                        count += 1
        
            if count == 0:
                ans = False
                break

if ans:
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np
H,W=map(int,input().split())
X=np.array([list(input()) for _ in range(H)])
Y=np.array([[0]*(W+2)]*(H+2))

for i in range(H):
  for j in range(W):
    if X[i][j]=='
      Y[i+1][j+1]=1
      
hantei = True      
for i in range(1,H+1):
  for j in range(1,W+1):
    if Y[i][j]==1:
      if Y[i-1][j]==0 and Y[i+1][j]==0 and Y[i][j+1]==0 and Y[i][j-1]==0:
        hantei =False
        break
print('Yes' if hantei else'No')

Solution (Python):
H,W=map(int,input().split())
s=[[0 for x in range(W+2)] for y in range(H+2)]
for y in range(1,H+1):
	t=input()
	for i in range(W):
		if t[i]=='
			s[y][i+1]=1

for y in range(1,H+1):
	for x in range(1,W+1):
		if s[y][x]==1:
			for d in [[-1,0],[1,0],[0,-1],[0,1]]:
				f=False
				if s[y+d[0]][x+d[1]]==1:
					f=True
					break
			if f==False:
				print('No')
				exit()

print('Yes')

Solution (Python):
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   i>=1 and S[i-1][j]=="
        continue
      elif i<=H-2 and S[i+1][j]=="
        continue
      elif j>=1 and S[i][j-1]=="
        continue
      elif j<=W-2 and S[i][j+1]=="
        continue
      else:
        print("No");exit()
print("Yes")

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

Solution (Python):
a,b = list(map(int, input().split()))

cs = []
cs.append("." * (b+2))
for i in range(a):
  s = "." + input() + "."
  cs.append(s)
cs.append("." * (b+2))

ans = True
for i in range(a):
  for j in range(b):
    if cs[i][j] == "
      if cs[i-1][j] == "." and cs[i][j-1] == "." and cs[i+1][j] == "." and cs[i][j+1] == ".":
        ans = False
        break
    if not ans:
      break
  if not ans:
    break
if ans:
  print("Yes")
else:
  print("No")

Solution (Python):
h,w=map(int,input().split())

grid=[None]*h
for i in range(h):
  grid[i]=input()
  
def isOk(y,x):
  if y-1>=0 and grid[y-1][x]=="
    return True
  if y+1<h and grid[y+1][x]=="
    return True
  if x-1>=0 and grid[y][x-1]=="
    return True
  if x+1<w and grid[y][x+1]=="
    return True
  return False
  
for i in range(h):
  for j in range(w):
    if grid[i][j]=="
      if not isOk(i,j):
        print("No")
        exit(0)
print("Yes")

Solution (Python):
H, W = map(int,input().split())
s = [list(input()) for i in range(H)]
ans = "Yes"
for i in range(H):
    for j in range(W):
        tmp = 1
        if s[i][j] == "
            tmp = 0
            if i > 0:
                if s[i-1][j] == "
                    tmp = 1
            if i < H - 1:
                if s[i+1][j] == "
                    tmp = 1
            if j > 0:
                if s[i][j-1] == "
                    tmp = 1
            if j < W - 1:
                if s[i][j+1] == "
                    tmp = 1
            if tmp == 0:
                ans ="No"
                break
    if tmp == 0:
        break
print(ans)

Solution (Python):
def judge(L,i,j):
    a=0
    if L[i][j]=="
        a= (L[i-1][j]!="
        and L[i][j-1]!="
    return a

h,w=map(int,input().split())
A=[input() for _ in range(h)]
ans=0

for i in range(h):
    A[i]="/" + A[i] + "/"
 
A.insert(0, ['/']*(w+2))
A.append(['/']*(w+2))

for i in range(h+2):
    for j in range(w+2):
        if judge(A,i,j)==1:
            ans=1

print("Yes" if ans==0 else "No")

Solution (Python):
def judge(L,i,j):
    a=0
    if L[i][j]=="
        a= (L[i-1][j]!="
        and L[i][j-1]!="
    return a

def judge_ed(L,i,j):
    a=0
    if L[i][j]=="
        if i == 0:
            a= (L[i+1][j]!="
        elif i == h-1:
            a= (L[i-1][j]!="
        elif j == 0:
            a= (L[i-1][j]!="
        else:
            a= (L[i-1][j]!="
    return a

h,w=map(int,input().split())
A=[input() for _ in range(h)]
ans=0

for i in range(h):
    for j in range(w):
        a=0
        if i in (0,h-1) and j in (0,w-1):a=0
        elif i in (0,h-1) or j in (0,w-1):
            a = judge_ed(A,i,j)
        else:a = judge(A,i,j)
        if a==1:
            ans=1

print("Yes" if ans==0 else "No")

Solution (Python):
def examC():
    H, W = LI()
    S = [SI() for _ in range(H)]
    ans = "Yes"
    for i in range(H):
        for j in range(W):
            if S[i][j]=="
                if (i>0 and S[i-1][j]==".") or i==0:
                    if (H-1>i and S[i+1][j]==".") or i==H-1:
                        if (j>0 and S[i][j-1]==".") or j==0:
                            if (W-1>j and S[i][j+1]==".") or j==H-1:
                                ans = "No"
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()

Solution (Python):
h, w = map(int, input().split())

S = [[x for x in str(input())] for _ in range(h)]

for i in range(h):
    S[i].insert(0, '/')
    S[i].append('/')

S.insert(0, ['/']*(w+2))
S.append(['/']*(w+2))

count = 0

for j in range(1, h+1):
    for k in range(1, w+1):
        if S[j][k] == '
            count += 1
            if S[j-1][k].count('
                count -= 1

if count == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
H, W = map(int,input().split())
s = [[i for i in list(input())] for j in range(H)]
dx = [0,0,-1,1]
dy = [-1,1,0,0]
 
for i in range(H):
    for j in range(W):
        if s[i][j] == ".": continue
 
        
        for k in range(4):
            ni = i + dy[k]
            nj = j + dx[k]
 
            if ni < 0 or ni >= H: continue
            if nj < 0 or nj >= W: continue
 
            if s[ni][nj] == "
            if k == 3:
                print("No")
                exit()
 
print("Yes")

Solution (Python):
import numpy as np
H, W = map(int, input().split())
grid = np.zeros((H, W), dtype="unicode")
for h in range(H):
    input_ = input()
    for w in range(W):
        grid[h, w] = input_[w]
    
h_candi = [0, 0, 1, -1]
w_candi = [1, -1, 0, 0]

cannot_flag = 0
for h in range(H):
    if cannot_flag:
        break
    for w in range(W):
        if grid[h, w] == ".":
            continue
        count = 0
        for h_, w_ in zip(h_candi, w_candi):
            h_idx = h + h_
            w_idx = w + w_
            if (h_idx < 0) or (h_idx >= H):
                continue
            if (w_idx < 0) or (w_idx >= W):
                continue
            if grid[h_idx, w_idx] == "
                count += 1
        if count == 0:
            cannot_flag = 1
            break

if cannot_flag:
    print("No")
else:
    print("Yes")

Solution (Python):
h, w = map(int, input().split())

s = [input() for _ in range(h)]

s2 = []

for i in range(h + 2):
    if i == 0 or i == h + 1:
        s2.append("." * (w + 2))
    else:
        s2.append("." + s[i - 1] + ".")


c = []

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if s2[i][j] == "
            c.append(
                (s2[i - 1][j] == "
                + (s2[i + 1][j] == "
                + (s2[i][j - 1] == "
                + (s2[i][j + 1] == "
            )


if c.count(0) > 0:
    print("No")
else:
    print("Yes")

Solution (Python):
H,W=map(int,input().split())
S = [list(str(input())) for i in range(H)]
judge=True
for i in range(H):
    for j in range(W):
        if S[i][j]=='
            judge1=True
            judge2=True
            judge3=True
            judge4=True
            
            try:S[i][j-1]
            except IndexError:judge1=False
            else:
                if S[i][j-1]=='.':
                    judge1=False
                    
            try:S[i][j+1]
            except IndexError:judge2=False
            else:
                if S[i][j+1]=='.':
                    judge2=False
                    
            try:S[i+1][j]
            except IndexError:judge3=False
            else:
                if S[i+1][j]=='.':
                    judge3=False
                    
            try:S[i-1][j]
            except IndexError:judge4=False
            else:
                if S[i-1][j]=='.':
                    judge4=False

            if judge1==False and judge2==False and judge3==False and judge4==False:
                judge=False
                break

    if judge==False:break


if judge:print('Yes')
else:print('No')

Solution (Python):

def getRow(graph, index):
  return graph[index]
def getElem(row, index):
  return row[index]
def getAbove(graph, h, w):
  try:
    return getElem(getRow(graph, h-1), w)
  except:
    return "
def getBelow(graph, h, w):
  try:
    return getElem(getRow(graph, h+1), w)
  except:
    return "
def getRight(graph, h, w):
  try:
    return getElem(getRow(graph, h), w+1)
  except:
    return "
def getLeft(graph, h, w):
  try:
    return getElem(getRow(graph, h), w-1)
  except:
    return "


h, w = [int(x) for x in input().split()]
graph = []
for hh in range(h):
  graph.append(input())



pos = "Yes"
for height in range(h):
  if pos == "No":
    break
  for width in range(w):
    element = getElem(getRow(graph, height), width)
    if element == ".":
      continue
    else:
      if getAbove(graph, height, width) == "
        continue
      elif getBelow(graph, height, width) == "
        continue
      elif getRight(graph, height, width) == "
        continue
      elif getLeft(graph, height, width) == "
        continue
      else:
        pos = "No"
        break


print(pos)

Solution (Python):
h,w = map(int,input().split())

sll = []

for _ in range(h):
    sl = list(input())
    sll.append(sl)

for i in range(h):
    for j in range(w):
        if sll[i][j] == "
            flag = False
            if j+1 < w:
                if sll[i][j+1] == "
                    flag = True
            if j-1 >= 0:
                if sll[i][j-1] == "
                    flag = True
            if i+1 < h:
                if sll[i+1][j] == "
                    flag = True
            if i-1 >= 0:
                if sll[i-1][j] == "
                    flag = True
            if flag == False:
                print("No")
                import sys
                sys.exit()

print("Yes")

Solution (Python):
hw = [int(i) for i in input().split()]
h = hw[0]
w = hw[1]
rows = []
possible = True
for i in range(h):
  rows.append(input())
i = 0
if h==1 and w==1:
  if rows[0]=='
    possible = False
elif h==1 and w>1:
  i = 0
  while i<w:
    if rows[0][i]=='
      if i==0:
        if rows[0][i+1]=='.':
          possible = False
          break
      elif i==w-1:
        if rows[0][i-1]=='.':
          possible = False
          break
      else:
        if rows[0][i+1]=='.' and rows[0][i-1]=='.':
          possible = False
          break
    i+=1
elif h>1 and w==1:
  i = 0
  while i<h:
    if rows[i][0]=='
      if i==0:
        if rows[i+1][0]=='.':
          possible = False
          break
      elif i==h-1:
        if rows[i-1][0]=='.':
          possible = False
          break
      else:
        if rows[i+1][0]=='.' and rows[i-1][0]=='.':
          possible = False
          break
    i+=1
else:
  while i<h:
    j = 0
    while j<w:
      if rows[i][j]=='
        if i==0 and j==0:
          if rows[i][j+1]=='.' and rows[i+1][j]=='.':
            possible=False
            break
        elif i==0 and j==w-1:
          if rows[i+1][j]=='.' and rows[i][j-1]=='.':
            possible = False
            break
        elif i==h-1 and j==0:
          if rows[i-1][j]=='.' and rows[i][j+1]=='.':
            possible = False
            break
        elif i==h-1 and j==w-1:
          if rows[i-1][j]=='.' and rows[i][j-1]=='.':
            possible = False
            break
        elif i==0 and j>0:
          if rows[i][j+1]=='.' and rows[i][j-1]=='.' and rows[i+1][j]=='.':
            possible=False
            break
        elif i>0 and j==0:
          if rows[i+1][j]=='.' and rows[i-1][j]=='.' and rows[i][j+1]=='.':
            possible = False
            break
        elif i>0 and j==w-1:
          if rows[i+1][j]=='.' and rows[i-1][j]=='.' and rows[i][j-1]=='.':
            possible = False
            break
        elif i==h-1 and j>0:
          if rows[i][j+1]=='.' and rows[i-1][j]=='.' and rows[i][j-1]=='.':
            possible = False
            break
        else:
          if rows[i+1][j]=='.' and rows[i-1][j]=='.' and rows[i][j+1]=='.' and rows[i][j-1]=='.':
            possible = False
            break
      j+=1
    if possible==False:
      break
    i+=1
if possible==False:
  print("No")
else:
  print("Yes")

Solution (Python):
H,W=map(int,input().split())
S=["."+input()+"." for i in range(H)]
field=["."*(W+2)]+S+["."*(W+2)]

flag=0

for k in range(1,H+1):
    for j in range(1,W+1):
        if field[k][j]=='
            flag=1

if flag==1:
    print('No')
else:     
    print('Yes')

Solution (Python):
import sys
h, w = map(int, input().split(" "))
p = []
for i in range(h):
  l = []
  s = input()
  for j in range(w):
    l.append(s[j])
  p.append(l)
  
         
for i in range(h):
  for j in range(w):
    if p[i][j] == "
      try:
        if p[i-1][j] == "
          continue
      except IndexError:
        pass
      try:
        if p[i][j+1] == "
          continue
      except IndexError:
        pass
      try:
        if p[i+1][j] == "
          continue
      except IndexError:
        pass
      try:
        if p[i][j-1] == "
          continue
      except IndexError:
        pass
      print("No")
      sys.exit()
      
print("Yes")

Solution (Python):
h,w=map(int,input().split())
dx=[-1,1,0,0]
dy=[0,0,-1,1]
a=[]
for i in range(h):
    a.append(list(input()))
for i in range(h):
    for j in range(w):
        if a[i][j]=="
            frag=False
            if j-1>=0 and a[i][j-1]=="
                frag=True
            if j+1<=w-1 and a[i][j+1]=="
                frag=True
            if i-1>=0 and a[i-1][j]=="
                frag=True
            if i+1<=h-1 and a[i+1][j]=="
                frag=True
            if frag==False:
                print("No")
                exit()
print("Yes")

Solution (Python):
h, w = map(int, input().split())
grid = [list(input()) for _ in range(h)]

check = [(-1, 0), (0, -1), (1, 0), (0, 1)]
for j in range(h):
  for i in range(w):
    if grid[j][i] == "
      temp = [(i+cx, j+cy) for cx, cy in check if (0<= i+cx <w and 0<= j+cy <h)]
      count = 0
      for t_cx, t_cy in temp:
        if grid[t_cy][t_cx] == "
          count += 1
      if count == 0:
        print("No")
        exit()
print("Yes")

Solution (Python):
y,x=map(int,input().split())
s=[]
ans='Yes'
for i in range(y):
    s.append(list(input()))
for j in range(y):
    for k in range(x):
        if s[j][k]=='
            if j==y-1:
                if k==x-1:
                    if s[j][k]!=s[j-1][k] and s[j][k]!=s[j][k-1]:
                        ans='No'
                        break
                elif k==0:
                    if s[j][k]!=s[j-1][k] and s[j][k]!=s[j][k+1]:
                        ans='No'
                        break
                else:
                    if s[j][k]!=s[j-1][k] and s[j][k]!=s[j][k+1] and s[j][k]!=s[j][k-1]:
                        ans='No'
                        break
            elif j==0:
                if k==x-1:
                    if s[j][k]!=s[j+1][k] and s[j][k]!=s[j][k-1]:
                        ans='No'
                        break
                elif k==0:
                    if s[j][k]!=s[j+1][k] and s[j][k]!=s[j][k+1]:
                        ans='No'
                        break
                else:
                    if s[j][k]!=s[j+1][k] and s[j][k]!=s[j][k+1] and s[j][k]!=s[j][k-1]:
                        ans='No'
                        break
            else:
                if k==x-1:
                    if s[j][k]!=s[j+1][k] and s[j][k]!=s[j][k-1] and s[j][k]!=s[j-1][k]:
                        ans='No'
                        break
                elif k==0:
                    if s[j][k]!=s[j+1][k] and s[j][k]!=s[j][k+1] and s[j][k]!=s[j-1][k]:
                        ans='No'
                        break
                else:
                    if s[j][k]!=s[j+1][k] and s[j][k]!=s[j][k+1] and s[j][k]!=s[j][k-1] and s[j][k]!=s[j-1][k]:
                        ans='No'
                        break
print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

H, W = MAP()
s = [input() for _ in range(H)]

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
for i in range(H):
	for j in range(W):
		if s[i][j] == '
			for sx, sy in zip(dx, dy):
				y = i+sy
				x = j+sx
				if 0 <= y <= H-1 and 0 <= x <= W-1:
					if s[y][x] == '
						break
			else:
				print("No")
				sys.exit()
else:
	print("Yes")

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

Solution (Python):
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]=='
            print('No')
            exit()

print('Yes')

Solution (Python):
H, W = map(int,input().split())
grid = ['.'*(W+2)]
for _ in range(H):
    tmp = input()
    tmp = '.' + tmp + '.'
    grid.append(tmp)
grid.append('.'*(W+2))
for i in range(1,H+1):
    for k in range(1,W+1):
        if grid[i][k] == '.':
            continue
        if grid[i][k+1] != '
            if grid[i+1][k] != '
                print('No')
                exit()
print('Yes')

Solution (Python):
H,W=map(int,input().split())

L=[]
l=["." for i in range(W+2)]
L.append(l)
for i in range(H):
    a=list(input())
    a=["."]+a+["."]
    L.append(a)
L.append(l)


X=[1,-1,0,0]
Y=[0,0,1,-1]

for i in range(1,H+1):
    for j in range(1,W+1):
        if L[i][j]=="
            F=1
            for k in range(4):
                if L[i+X[k]][j+Y[k]]=="
                    F=0
            if F==1:
                print("No")
                exit()
print("Yes")

Solution (Python):
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+1][j+1]=='
            if S[i][j+1]=='.' and S[i+2][j+1]=='.' and S[i+1][j]=='.' and S[i+1][j+2]=='.':
                flag = 1
print('Yes' if flag == 0 else 'No')

Solution (Python):
H, W = map(int, input().split())

s = []
s.append("
for i in range(H):
    tmp = "
    tmp += input()
    tmp += "
    s.append(tmp)
s.append("

flag = True
for i in range(1, len(s)-1):
    for j in range(1, W+1):
        if s[i][j] == "
            if (s[i][j-1] == "." and s[i][j+1] == "." 
                and s[i-1][j] == "." and s[i+1][j] == "."):
                flag = False
                break
            
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):
from sys import stdin
import numpy as np

h,w = [int(x) for x in stdin.readline().rstrip().split()]
li = [["." for i in range(w+2)]for j in range(h+2)]

for i in range(h):
    s = stdin.readline().rstrip()
    for j in range(w):
        li[i+1][j+1] = s[j]

for i in range(1,h-1):
    for j in range(1,w-1):
        if li[i][j-1] == "." and li[i][j] == "
            if li[i+1][j] != "
                print("No")
                exit()
print("Yes")

Solution (Python):
h, w = map(int, input().split())

s = [input() for _ in range(h)]

ans = 'Yes'

for i in range(1, h-1):
    for j in range(1, w-1):
        if s[i][j] == '
            ans = 'No'

print(ans)

Solution (Python):
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]=='
            F=0
            break

print(['No','Yes'][F])

Solution (Python):
h, w = map(int, input().split())

s = [input() for _ in range(h)]

ans = 'Yes'

for i in range(1, h-1):
    for j in range(1, w-1):
        if s[i][j] == '
            ans = 'No'

print(ans)

Solution (Python):
m,n=map(int,input().split())
hoge=[[0 for i in range(n+2)] for j in range(m+2)]
for i in range(m):
  sss=input()
  for j in range(n):
    if(sss[j]=="
      hoge[1+i][1+j]=1
    

flag=True
for i in range(m):
  for j in range(n):
    if(hoge[1+i][1+j]==1):
      ans=0
      
      ans=max(hoge[i][1+j],hoge[1+i][j],hoge[2+i][1+j],hoge[1+i][2+j])
      if(ans==0):
        flag=False
        
if(flag):
  print("Yes")
else:
  print("No")

Solution (Python):
def check(i, j, w, h, s):
    if (i+1<h and s[i+1][j]=="
        return True
    if (i-1>=0 and s[i-1][j]=="
        return True
    if (j+1<w and s[i][j+1]=="
        return True
    if (j-1>=0 and s[i][j-1]=="
        return True
    return False

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]=="
            if check(i, j, w, h, s):
                True
            else:
                print("No")
                exit()

print("Yes")

Solution (Python):
def check(i, j, w, h, s):
    if (i + 1 < h and s[i + 1][j] == "
        return True
    if (i - 1 >= 0 and s[i - 1][j] == "
        return True
    if (j + 1 < w and s[i][j + 1] == "
        return True
    if (j - 1 >= 0 and s[i][j - 1] == "
        return True
    return False


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] == "
            if check(i, j, w, h, s):
                True
            else:
                print("No")
                exit()
print("Yes")

Solution (Python):

def check(i, j, w, h, s):
  if(i + 1 < h and s[i+1][j] == "
    return True
  if(i - 1 >= 0 and s[i-1][j] == "
    return True
  if(j - 1 >= 0 and s[i][j-1] == "
    return True
  if(j + 1 < w and s[i][j+1] == "
    return True
  return False

h,w = list(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] == "
      if(check(i, j, w, h, s)):
        True
      else:
        print("No")
        exit()
print("Yes")

Solution (Python):

H, W = map(int,input().split())
S = [list(str(input())) for i in range(H)]

for h in range(H):
    for w in range(W):
        if S[h][w] == '
            tmp = 0
            if w != W-1:
                if S[h][w+1] == '
                    tmp = 1
            if h != 0:
                if S[h-1][w] =='
                    tmp = 1
            if h != H-1:
                if S[h + 1][w] == '
                    tmp = 1
            if w != 0:
                if S[h][w - 1] == '
                    tmp = 1
            if tmp == 0:
                print('No')
                exit()
print('Yes')

Solution (Python):
def get_neighbors(r, c):
    if 0 < r:
        yield r - 1, c
    if r < h - 1:
        yield r + 1, c
    if 0 < c:
        yield r, c - 1
    if c < w - 1:
        yield r, c + 1


def solve(h, w, s):
    for r in range(h):
        for c in range(w):
            if s[r][c] == '
                if all(s[nr][nc] == '.' for nr, nc in get_neighbors(r, c)):
                    return False
    return True


if __name__ == '__main__':
    h, w = map(int, input().split())
    s = [input() for _ in range(h)]

    print('Yes' if solve(h, w, s) else 'No')