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):
h, w = map(int, input().split())

s = []
for i in range(h):
    s.append([x for x in input().split()])


for i in range(h):
    for j in range(w):
        cnt = 0
        shape = 0

        if s[i][0][j] == "
            if i != 0 :
                cnt += 1
                if s[i-1][0][j] == "
                    shape += 1
            if i != h-1:
                cnt += 1
                if s[i+1][0][j] == "
                    shape += 1
            if j != 0:
                cnt += 1
                if s[i][0][j-1] == "
                    shape += 1
            if j != w-1:
                cnt += 1
                if s[i][0][j+1] == "
                    shape += 1

            if shape == 0:
                print("No")
                exit(0)

print("Yes")

Solution (Python):
def main():
    h, w = [int(e) for e in input().split()]
    s = [input() for i in range(h)]

    for hi in range(h):
        for wi in range(w):
            if s[hi][wi] == '.':
                continue

            flag = False
            for d in [[-1, 0], [1, 0], [0, -1], [0, 1]]:
                hp = hi + d[0]
                wp = wi + d[1]
                if hp < 0 or hp >= len(s) or wp < 0 or wp >= len(s[0]):
                    continue

                if s[hp][wp] == '
                    flag = True

            if not flag:
                print('No')
                exit()

    print('Yes')


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    H, W = map(int, input().split())
    matrix = [list(input()) for _ in range(H)]
    for r in matrix:
        r.insert(0, ".")
        r.append(".")
    matrix.insert(0, ["."] * (W + 2))
    matrix.append(["."] * (W + 2))

    ans = "Yes"
    for r in range(1, H + 1):
        for c in range(1, W + 1):
            if matrix[r][c] == ".":
                continue
            if matrix[r-1][c] == "." and matrix[r+1][c] == "." and matrix[r][c-1] == "." and matrix[r][c+1] == ".":
                ans = "No"
                break
        if ans == "No":
            break
    print(ans)

if __name__ == '__main__':
    main()

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

dx=[-1,0,1,0]
dy=[0,1,0,-1]
for i in range(h):
    for j in range(w):
        if grid[i][j]=='
            flag=False
            for k in range(4):
                x=i+dx[k]
                y=j+dy[k]
                if 0<=x<h and 0<=y<w and grid[x][y]=='
                    flag=True
                    break
            if flag:
                continue
            else:
                print('No')
                exit()
print('Yes')

Solution (Python):
H, W = map(int, input().split())
gridgraph = ['.'*(W+2)]
for _ in range(H):
    area = input()
    gridgraph.append('.'+area+'.')
gridgraph.append('.'*(W+2))


flag = True
for i in range(1, H+1):
    for j in range(1, W+1):
        if gridgraph[i][j] == '
            if gridgraph[i-1][j] == '
                continue
            else:
                flag = False
if flag:
    print('Yes')
else:
    print('No')

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

Solution (Python):
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]=='
      f=1
      for dx,dy in ((1,0),(0,1),(-1,0),(0,-1)):
        nx,ny=x+dx,y+dy
        if nx<0 or nx>=h or ny<0 or ny>=w:
          continue
        elif g[nx][ny]=='
          f=0
      if f:
        print('No')
        break
  else:
    continue
  break
else:
  print('Yes')

Solution (Python):
h,w=map(int,input().split())
data=[[0 for i in range(w+2)] for j in range(h+2)]
for j in range(h):
    s=input()
    for i in range(w):
        if s[i]=="
            data[j+1][i+1]=1
flag=True
for i in range(1,h+2):
    for j in range(1,w+2):
        if data[i][j]==1 and data[i-1][j]==data[i+1][j]==data[i][j-1]==data[i][j+1]==0:
            flag=False
            break
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):
h,w=map(int,input().split())
s= [input() for _ in range(h)]
neighbor = [(-1,0),(0,-1),(1,0),(0,1)]
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            continue
        else:
            flag = False
            for nei in neighbor:
                n = (i+nei[0],j+nei[1])
                if n[0]<0 or n[1]<0 or n[0]>=h or n[1]>=w:
                    continue
                if s[n[0]][n[1]] == '
                    flag = True
                    break
            if flag == False:
                print('No')
                exit()
print('Yes')

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

s = []
for _ in range(h):
    s.append(list(input()))

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

for i in range(h):
    for j in range(w):
        if s[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 h in range(H) :
    for w in range(W) :
        if S[h][w] == "
            check = False
            for a in [-1,1] :
                if h+a >= 0 and S[h+a:] :
                    if S[h+a][w] == "
                        check = True
            for b in [-1,1] :
                if w+b >= 0 and S[h][w+b:] :
                    if S[h][w+b]== "
                        check = True
            if check == False :
                ans = "No"

print(ans)

Solution (Python):
H, W = map(int,input().split())
mp = [list(input()) for i in range(H)]
for i in range(H):
    mp[i].insert(0,'.')
    mp[i].append('.')
lo = ['.' for i in range(W+2)]
mp.insert(0,lo)
mp.append(lo)

dir =[[-1,0], [0,-1], [0,1], [1,0]]
def check(x,y):
    if mp[x][y] =='
        bw =False
        for i in range(len(dir)):
            if mp[x + dir[i][0]][y + dir[i][1]] =='
                bw = True
        if bw == True:
            return True
        else:
            return False
    else:
        return True

ok =True
for i in range(1,H+1):
    for k in range(1,W+1):
        if check(i,k) == False:
            ok = False
            break

if ok == True:
    print('Yes')
else:
    print('No')

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

status = []
for i in range(H):
    status.append([i for i in input()])

for i in range(H):
    for j in range(W):
        if status[i][j] == "
            if i - 1 >= 0:
                if status[i - 1][j] == "
                    continue
            if i + 1 <= H -1:
                if status[i + 1][j] == "
                    continue
            if j - 1 >= 0:
                if status[i][j - 1] == "
                    continue
            if j + 1 <= W -1:
                if status[i][j + 1] == "
                    continue
            print("No")
            exit()
print("Yes")

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

status = []
for i in range(H):
    status.append([i for i in input()])

for i in range(H):
    for j in range(W):
        if status[i][j] == "
            flag = 0
            if i - 1 >= 0:
                if status[i - 1][j] == "
                    flag = 1
                    continue
            if i + 1 <= H -1:
                if status[i + 1][j] == "
                    flag = 1
                    continue
            if j - 1 >= 0:
                if status[i][j - 1] == "
                    flag = 1
                    continue
            if j + 1 <= W -1:
                if status[i][j + 1] == "
                    flag = 1
                    continue
            if flag == 0:
                print("No")
                exit()
print("Yes")

Solution (Python):
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

H, W = na()
M = ncl(H)
dx, dy = [0, 1, -1, 0], [1, 0, 0, -1]

flag = True
for i in range(H):
    for j in range(W):
        if M[i][j] == '
            ok = False
            for k in range(4):
                nx, ny = j + dx[k], i + dy[k]
                if 0 <= nx and nx < W and 0 <= ny and ny < H and M[ny][nx] == '
                    ok = True
            if not ok:
                flag = False

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

Solution (Python):
H,W=map(int,input().split())
s=[0 for i in range(0,H)]
for i in range(0,H):
    s[i]=input().split()

black=[(i,j) for i in range(0,H) for j in range(0,W) if s[i][0][j]=='

flag=0
for i in range(0,H):
    for j in range(0,W):
        if (i,j) in black:
            if not ((i+1,j) in black or (i,j+1) in black or (i-1,j) in black or (i,j-1) in black):
                flag=1
if flag==0:
    print('Yes')
else:
    print('No')

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

ans = "Yes"
for i in range(h):
    for j in range(w):
        if mass[i][j] == "
            if i < h-1:
                if mass[i+1][j] == "
                    continue
            if 0 < i:
                if mass[i-1][j] == "
                    continue
            if j < w-1:
                if mass[i][j+1] == "
                    continue
            if 0 < j:
                if mass[i][j-1] == "
                    continue
            ans = "No"
            break

print(ans)

Solution (Python):



def check(all_S_list):
    delta_list = [        [-1,0],
                   [0,-1],        [0,1],
                           [1,0]
                 ]

    for i in range(H):
        for j in range(W):
            
            if all_S_list[i][j] == "
            
                next_too_flag = False
                for d_i,d_j in delta_list:
                    check_i = i + d_i
                    check_j = j + d_j
                    
                    if check_i < 0 or (H-1) < check_i: continue
                    if check_j < 0 or (W-1) < check_j: continue
 
                    if all_S_list[check_i][check_j] == "
                        next_too_flag = True
                
                if next_too_flag == False:
                    return False
    
    return True


H,W = list(map(int, input().rstrip().split()))
all_S_list = [ list(input().strip()) for _ in range(H) ]

if check(all_S_list):
    print("Yes")
else:
    print("No")

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

t=".."
for _ in range(w):
  t += "."

s=[]
s.append(t)
for i in range(h):
  s.append("." + input() + ".")
s.append(t)
f=True
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] != "
          f=False
if f:
  print("Yes")
else:
  print("No")

Solution (Python):
h,w=map(int,input().split())
dx=[1,-1,0,0]
dy=[0,0,1,-1]
s=[]
for i in range(h):
    s.append(list(input()))
for i in range(h):
    for j in range(w):
        if s[i][j]=="
            for t in range(4):
                if all(s[i+dy[t]][j+dx[t]]!="
                    print("No")
                    exit(0)
                else:
                    pass
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):
    S=["."]+list(input())+["."]
    L.append(S)
L.append(l)

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

Solution (Python):
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 s[i-1][j]=='.' and s[i][j-1]=='.' and s[i][j+1]=='.' and s[i+1][j]=='.':
                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]=='
      flg = 0
      flg += 1 if i-1>=0 and S[i-1][j]=='
      flg += 1 if i+1<H and S[i+1][j]=='
      flg += 1 if j-1>=0 and S[i][j-1]=='
      flg += 1 if j+1<W and S[i][j+1]=='
      if flg==0:
        print('No')
        exit(0)
print('Yes')

Solution (Python):
h,w=map(int,input().split())
s=[]
for i in range(h):
    s_i=input()
    s.append(s_i)
ans="Yes"
for i in range(h):
    for j in range(w):
        if s[i][j]=="
            if i-1>=0 and s[i-1][j]=="
                continue
            elif i+1<h and s[i+1][j]=="
                continue
            elif j-1>=0 and s[i][j-1]=="
                continue
            elif j+1<w and s[i][j+1]=="
                continue
            else:
                ans="No"
        if ans=="No":
            break
    if ans=="No":
        break
print(ans)

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

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

flag = False
for x in range(h):
    for y in range(w):
        if grid[x, y] == '.':
            continue
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if nx >= 0 and nx < h and ny >= 0 and ny < w:
                if grid[nx, ny] == '
                    break
        else:
            flag = True
            break
    if flag:
        break

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

Solution (Python):
H, W = map(int, input().split())
s = []
OK = True




for _ in range(H):
    s.append(input())
for i in range(H):
    for j in range(W):
        OK1 = True
        OK2 = True
        OK3 = True
        OK4 = True
        if s[i][j] == '
            if i != 0:
                if s[i-1][j] != '
                    OK1 = False
            if i != H-1:
                if s[i+1][j] != '
                    OK2 = False
            if j != 0:
                if s[i][j-1] != '
                    OK3 = False
            if j != W-1:
                if s[i][j+1] != '
                    OK4 = False
        if OK1 or OK2 or OK3 or OK4:
            continue
        else:
            OK = False

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

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

for i in range(h):
    for j in range(w):
        if s[i][j] == '
            chk = False
            
            if not i == 0:
                if s[i-1][j] == '
                    chk = True
            
            if not i == h-1:
                if s[i+1][j] == '
                    chk = True
            
            if not j == 0:
                if s[i][j-1] == '
                    chk = True
            
            if not j == w-1:
                if s[i][j+1] == '
                    chk = True
            if chk:
                pass
            else:
                print('No')
                exit()

print('Yes')

Solution (Python):
import itertools
import math
import sys
from collections import Counter
from fractions import gcd
from functools import reduce

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

for i in range(h):
    flag = False
    for j in range(w):
        if s[i][j] == "
            con1 = True
            con2 = True
            con3 = True
            con4 = True
            if 0 <= i + 1 < h:
                if s[i + 1][j] == ".":
                    con1 = False
            if 0 <= j - 1 < w:
                if s[i][j - 1] == ".":
                    con2 = False
            if 0 <= i - 1 < h:
                if s[i - 1][j] == ".":
                    con3 = False
            if 0 <= j + 1 < w:
                if s[i][j + 1] == ".":
                    con4 = False
            if con1 == con2 == con3 == con4 == False:
                flag = True
                
                print("No")
                break
    if flag:
        break
else:
    print("Yes")

Solution (Python):
import sys
H,W=map(int,input().split())
smap=[input() for i in range(H)]
dx=[1,0,-1,0]
dy=[0,1,0,-1]

for i in range(H):
    for j in range(W):
        if(smap[i][j]=='
            t=True
            for k in range(4):
                ni=i+dx[k]
                nj=j+dy[k]
                if(ni<0 or ni>=H or nj<0 or nj>=W):
                    continue
                if(smap[ni][nj]=='
                    t=False
            if(t):
                print("No")
                sys.exit()
print("Yes")

Solution (Python):
h, w = list(map(int, input().split()))
s = [list(input()) for _ in range(h)]
diff = [[1, 0], [0, 1], [-1, 0], [0, -1]]

def a(s, h, w, diff):
    num, cnt = 0, 0
    for i in range(h):
        for j in range(w):
            if s[i][j]=='
                for k in diff:
                    i += k[0]
                    j += k[1]
                    if (0<=i and i<=h-1) and (0<=j and j<=w-1):
                        num += 1
                        if s[i][j]=='.':
                            cnt += 1
                    i -= k[0]
                    j -= k[1]
                if cnt==num:
                    return print('No')
            num, cnt = 0, 0
    return print('Yes')
a(s, h, w, diff)

Solution (Python):
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7



H, W = list(map(int, sys.stdin.buffer.readline().split()))
S = [sys.stdin.buffer.readline().decode().rstrip() for _ in range(H)]


def black(h, w):
    if 0 <= h < H and 0 <= w < W:
        return S[h][w] == '
    return False

def test(h, w):
    if S[h][w] == '.':
        return True
    cnt = 0
    cnt += black(h - 1, w)
    cnt += black(h + 1, w)
    cnt += black(h, w - 1)
    cnt += black(h, w + 1)
    return cnt >= 1


ok = True
for h, w in itertools.product(range(H), range(W)):
    ok &=test(h, w)
if ok:
    print('Yes')
else:
    print('No')

Solution (Python):
h,w=map(int,input().split())
s=[list(input()) for _ in range(h)]
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):
h,w=map(int,input().split())
s=[input() for i in range(h)]

dx=[0,1,0,-1]
dy=[1,0,-1,0]
for i in range(h):
    for j in range(w):
        if s[i][j]=='
            cnt=0
            for k in range(4):
                nx=i+dx[k]
                ny=j+dy[k]

                if 0<=nx<=h-1 and 0<=ny<=w-1:
                    if s[nx][ny]=='
                        cnt=1
            if cnt!=1:
                print('No')
                exit()

print('Yes')

Solution (Python):

h,w = map(int,input().split())
grid = [["."]*(w+2) for _ in range(h+2)]
for i in range(h):
    s = 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] == "
            if grid[i][j+1] == "."  and  grid[i+1][j] == "." and grid[i+2][j+1] == "." and grid[i+1][j+2] == ".":
                print("No")
                exit()
print("Yes")

Solution (Python):
H,W=map(int,input().split())
s=[[] for _ in range(H+2)]
s[0]="."*(W+2)
for i in range(H):
    s[i+1]="."+input()+"."
s[-1]="."*(W+2)

ans="Yes"

di=[0,0,1,-1]
dj=[1,-1,0,0]

def ch(i,j):
    for k in range(4):
        if s[i+di[k]][j+dj[k]]=="
            return True
    return False
            


for i in range(1,H+1):
    for j in range(1,W+1):
        if s[i][j]=="
            if ch(i,j):
                continue
            else:
                ans="No"
                break
                
print(ans)

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

Solution (Python):
def main():
    height, width = map(int, input().split(" "))
    grids = ["." * (width + 2)]
    for _ in range(height):
        grids.append("." + input() + ".")
    grids.append("." * (width + 2))
    is_possible = True
    for i in range(1, height + 1):
        for j in range(1, width + 1):
            if grids[i][j] == "
                if not (grids[i + 1][j] == "
                    is_possible = False
    if is_possible:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Solution (Python):

import math
import heapq
import bisect
import numpy as np
from collections import Counter


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

s = ['.'*(W+2)]
for i in range(H):
    row = input()
    s.append('.' + row + '.')
s.append('.'*(W+2))

flg = 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] == ".":
                flg = 0

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

Solution (Python):
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
                break
print("Yes" if a==0 else "No")

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

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 = [int(x) for x in input().split()]
s_lst = [input() for i in range(H)]
can = True
for i in range(H):
    for j in range(W):
        if s_lst[i][j] == '
            f1 = 0
            f2 = 0
            f3 = 0
            f4 = 0
            if 0 < i and s_lst[i - 1][j] == '.':
                f1 = 1
            if i < H - 1 and s_lst[i + 1][j] == '.':
                f2 = 1
            if 0 < j and s_lst[i][j - 1] == '.':
                f3 = 1
            if j < W - 1 and s_lst[i][j + 1] == '.':
                f4 = 1
            if f1*f2*f3*f4 == 1:
                can = False
print('Yes') if can else print('No')

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

"""考え方
普通に全探索して問題あるか無いかを確認して行く。
1行目、H行目、1列目、W列目だけは少し注意！！！
→0行目、H+1行目、0列目、W+1列目を追加する
"""

list_ = []
list_.append(['.' for i in range(W+2)])
for h in range(H):
  list_.append(list('.'+input()+'.'))
list_.append(['.' for i in range(W+2)])

ans = 'Yes'
for h in range(H):
  for w in range(W):
    
    if list_[h][w] == '
      if list_[h-1][w] == '.':
        if list_[h+1][w] == '.':
          if list_[h][w-1] == '.':
            if list_[h][w+1] == '.':
              ans = 'No'
              break

print(ans)

Solution (Python):
import sys
h,w = map(int,input().split())
s = [list(input()) for i in range(h)]
dx = [0,-1,1,0]
dy = [-1,0,0,1]

for i in range(h):
    for j in range(w):
        cnt = 0
        if  s[i][j] == "
            for k in range(4):
                nx = j + dx[k]
                ny = i + dy[k]
                if nx>=0 and ny>=0 and ny<h and nx<w:
                    if s[ny][nx] == "
                        cnt += 1
            if cnt == 0:
                print("No")
                sys.exit()
print("Yes")

Solution (Python):
h,w = map(int,input().split())
a = ["." for i in range(w+2)]
dot_map = [a]
for _ in range(h):
    l = list(input())
    l.insert(0, ".")
    l.append(".")
    dot_map.append(l)
dot_map.append(a)
breaker = 0

for i in range(1, h+1):
    if breaker == 1:
        break
    else:
        for j in range(1,w+1):
            if dot_map[i][j] == "
                flag = 0
                if dot_map[i-1][j] == "
                    flag += 1
                elif dot_map[i][j-1] == "
                    flag += 1
                elif dot_map[i][j+1] == "
                    flag += 1
                elif dot_map[i+1][j] == "
                    flag += 1
                if flag == 0:
                    breaker += 1
                    break

if breaker == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
h,w = map(int,input().split())
matrix = [[0]*(w+2) for _ in range(h+2)]
for hi in range(h):
    all_inp = input()
    for i,a in enumerate(all_inp):
        matrix[hi+1][i+1]= 1 if a == '

for ri,row in enumerate(matrix):
    for ci,column in enumerate(row):
        if column == 1:
            if row[ci-1] == 0 and row[ci+1] == 0 and matrix[ri-1][ci] == 0 and matrix[ri+1][ci] == 0:
                print('No')
                sys.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][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())

plan = []
for i in range(h):
  plan.append(input())

canvas = [[False] * w for _ in range(h)]

for i in range(h):
  for j in range(w - 1):
    if plan[i][j] == plan[i][j + 1] == '
      canvas[i][j] = canvas[i][j + 1] = True

for j in range(w):
  for i in range(h - 1):
    if plan[i][j] == plan[i + 1][j] == '
      canvas[i][j] = canvas[i + 1][j] = True

if all([all([plan[i][j] == '.' or canvas[i][j] for j in range(w)]) for i in range(h)]):
  print('Yes')
else:
  print('No')

Solution (Python):
h, w = list(map(int, input().split()))
graph = []
def check(s,t):
    if (0 <=  s <= w - 1) and (0 <= t <= h - 1):
        return True
    else:
        return False
def check_around(x,y):
    if check(x+1,y) and graph[y][x+1] == '
        return True
    if check(x,y+1) and graph[y+1][x] == '
        return True
    if check(x-1,y) and graph[y][x-1] == '
        return True
    if check(x,y-1) and graph[y-1][x] == '
        return True
    return False
for i in range(h):
    graph.append(list(input()))
for i in range(h):
    for j in range(w):
        if graph[i][j] == '
            if  not check_around(j,i):
                print("No")
                exit()
print("Yes")

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



def get_field(i, j):
    try:
        ret = field[i][j]
    except:
        ret = '.'
    return ret

ans = True
for i in range(H):
    for j in range(W):
        if field[i][j] == '
            up = get_field(i-1, j)
            down = get_field(i+1, j)
            left = get_field(i, j-1)
            right = get_field(i, j+1)
            if up == '
                ans = True
            else:
                ans = False
                break
    if ans == False:
        break

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

Solution (Python):
h, w = list(map(int, input().split()))
s = [["." for i in range(w+2)]]
for i in range(h):
    si = ["."]
    sie = list(input())
    for e in sie:
        si.append(e)
    si.append(".")
    s.append(si)
s.append(["." for i in range(w+2)])
ans = "Yes"
for i in range(1, h + 1):
    for j in range(1, w + 1):
        if s[i][j] == "
            if not ((s[i - 1][j] == "
                ans = "No"
print(ans)