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())
G = []
for i in range(H):
    G.append(list(input()))
fd = [[-1, 0], [1, 0], [0, 1], [0, -1]]
for i in range(H-1):
    for j in range(W-1):
        if G[i][j] == '
            boo = False
            for x, y in fd:
                if i+y < 0 or i+y >= H:
                    continue
                if j+x < 0 or j+y >= W:
                    continue
                if G[i+y][j+x] == '
                    boo = True
            if not boo:
                print('No')
                exit()
print('Yes')

Solution (Python):
H, W = map(int, input().split())
masu = []
for _ in range(H):
  tmp = list(input())
  masu.append(tmp)
  
directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]

for i in range(H):
  for j in range(W):
    if masu[i][j] == ".":
      continue
    is_ok = False
    for dy, dx in directions:
      new_y = i + dy
      new_x = j + dx
      if new_y >= H or new_x >= W:
        continue
      if masu[new_y][new_x] == "
        is_ok = True
        break
    if is_ok == False:
      print('No')
      quit()
print('Yes')

Solution (Python):
h,w=map(int,input().split())
s=[]
s.append("."*(w+2))
for _ in range(h):
    s.append("."+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]=="
            if s[i-1][j]=="." and s[i][j-1]=="." and s[i][j+1]=="."  and s[i+1][j]=="." :
                flag=False

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

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


x = [0,0,1,-1]
y = [1,-1,0,0]

ans = "Yes"
for i in range(h):
    for j in range(w):
        if s[i][j] == "
            flag = False
        else:
            continue
        for k in range(4):
                if 0<=i+x[k]<h and 0<=j+y[k]<w: 
                    if s[i+x[k]][j+y[k]] == "
                        flag = True
                    else:
                        continue
        if flag:
            continue
        else:
            print("No")
            exit()


print(ans)

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

Solution (Python):
def main():
    H,W=map(int,input().split())
    m=[input() for _ in range(H)]
    is_ok = True
    for h in range(H):
        for w in range(W):
            if m[h][w] == "
                if -1 < h-1 and m[h-1][w] == "
                    pass
                elif -1 < w-1 and m[h][w-1] == "
                    pass
                elif h+1 < H and m[h+1][w] == "
                    pass
                elif w+1 < W and m[h][w+1] == "
                    pass
                else:
                    print("No")
                    return
    print("Yes")
        
if __name__ == "__main__":
    main()

Solution (Python):
h,w = map(int, input().split())
S = [list(input()) for i in range(h)]
for i in range(h):
  S[i] = ["."] + S[i] + ["."]
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] == ".":
      pass
    else:
      if [S[i-1][j],S[i+1][j],S[i][j-1],S[i][j+1]] == ["."]*4:
        print("No")

        exit()
      
print("Yes")

Solution (Python):
h,w = map(int,input().split())
s = [0]*(h+2)
s[0] = ["."]*(w+2)
s[-1] = ["."]*(w+2)
for i in range(1,h+1):
    s[i] = ["."] + list(input()) + ["."]
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
                break
print(["No","Yes"][ans])

Solution (Python):



import os
import sys

from itertools import repeat







def main():
    H, W = map(int, input().split())

    S = list()

    for i in range(H):
        S.append(input())

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

    print("Yes")
    return


if __name__ == '__main__':
    main()

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

    for y in range(H):
        for x in range(W):
            if s[y][x] == '.':
                continue
            else:
                for dx,dy in [-1,0],[0,-1],[1,0],[0,1]:
                    nx = x + dx
                    ny = y + dy
                    if (0 <= nx < W) and (0 <= ny < H) and s[ny][nx] != '.':
                        break
                    elif (0 > nx) or (W <= nx) or (0 > ny) or (H <= ny):
                        continue
                    elif dx == 0 and dy == 1 and s[ny][nx] == '.':
                        return 'No'

    return 'Yes'

print(main())

Solution (Python):
def check_adjacents(S, i, j):
    return i > 0 and S[i-1][j] == '
           i < H - 1 and S[i+1][j] == '
           j > 0 and S[i][j-1] == '
           j < W - 1 and S[i][j+1] == '

def solution(H, W, S):
    for i in range(H):
        for j in range(W):
            if S[i][j] == '
                adjacents_sharp = check_adjacents(S, i, j)
                if not adjacents_sharp:
                    return 'No'
    return 'Yes'

H, W = map(int, input().split())
S = [input() for _ in range(H)]
print(solution(H, W, S))

Solution (Python):
h,  w =  map(int, input().split())
a = []
a.append("."*(w+2))
for _ in  range(h):
    a.append("."+input()+".")
a.append("."*(w+2))

ans  = "Yes"
for i in range(h+2):
    for j in  range(w+2):
        if a[i][j] == "
            if not(a[i-1][j] == "
                ans = "No"
                break
print(ans)

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

grid = [['.' for _ in range(W + 2)]]
for _ in range(H):
    g = ['.'] + [i for i in input()] + ['.']
    grid.append(g)

grid.append(['.' for _ in range(W + 2)])

f = 1
for h in range(1, H + 1):
    for w in range(1, W + 1):
        if grid[h][w] == '.':
            continue
        a = grid[h - 1][w] == '
        b = grid[h + 1][w] == '
        c = grid[h][w - 1] == '
        d = grid[h][w + 1] == '
        if not any([a, b, c, d]):
            f = 0
            break
    
    if not f:
        break

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

Solution (Python):
__DEUBG__ = 0

import math
import sys

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

board = [
  list(input())
  for _ in range(H)]

def calc(board, x, y):
    if board[x][y] == '
        for i,j in [
          (x, y-1),
          (x-1, y),
          (x+1, y),
          (x, y+1)
        ]:
            if 0 <= i <= H-1 and 0 <= j <= W-1:
                if board[i][j] == '
                    return
        print('No')
        exit()
    else:
        return

for i in range(H):
    for j in range(W):
        if __DEUBG__:
            print(i, j)
        calc(board, i, j)

print('Yes')

Solution (Python):

import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, W = lr()
S = np.array([list(sr()) for _ in range(H)])
black = S == '
is_ok = np.zeros_like(S, dtype=np.bool)
is_ok[1:, :] |= black[:-1, :]
is_ok[:-1, :] |= black[1:, :]
is_ok[:, 1:] |= black[:, :-1]
is_ok[:, :-1] |= black[:, 1:]
impossible = (black & (~is_ok)).any()
print('No' if impossible else 'Yes')

Solution (Python):

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, W = lr()
S = [sr() for _ in range(H)]
bl = True
for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            continue
        for dy, dx in zip([0, 1, 0, -1], [1, 0, -1, 0]):
            ny = i + dy
            nx = j + dx
            if 0 <= ny < H and 0 <= nx < W and \
                    S[ny][nx] == '
                break
        else:
            bl = False

print('Yes' if bl else 'No')

Solution (Python):
import numpy as np
h,w = list(map(int, input().split())) 
canvas = np.array([[np.nan]*w]*h).astype(int)

for i in range(h):
    s = input()
    for j in range(w):
        if( s[j] == '.'):
            canvas[i, j] = 0
        elif (s[j]=='
            canvas[i, j] = 1

ret = True
for i in range(h):
    for j in range(w):
        if( canvas[i, j] == 1):

            check = False
            ch = i-1
            cw = j
            if( (0 <= ch & ch < h) & (0 <= cw & cw < w)):  
                if( canvas[ch,cw] == 1):
                    check = True
            ch = i
            cw = j-1
            if( (0 <= ch & ch < h) & (0 <= cw & cw < w)):  
                if( canvas[ch,cw] == 1):
                    check = True
            ch = i
            cw = j+1
            if( (0 <= ch & ch < h) & (0 <= cw & cw < w)):  
                if( canvas[ch,cw] == 1):
                    check = True
            ch = i+1
            cw = j
            if( (0 <= ch & ch < h) & (0 <= cw & cw < w)):  
                if( canvas[ch,cw] == 1):
                    check = True  
            if check == False:
                ret = False
                break
    if ret == False:
        break
if ret:
    print('Yes')
else:
    print('No')

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

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

def check(i,j):
    for x,y in check_list:
        try: 
            if s_a[i+x][j+y] == '
                return True
        except:
            continue
    return False

ans = 'Yes'
for i in range(H):
    for j in range(W):
        if s_a[i][j] == '
            if check(i,j):
                continue
            else:
                ans = 'No'
                break
print(ans)

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

for i in range(1, h - 1):
    for j in range(1, w - 1):
        if grid[i][j] == '
            for a, b in dxy:
                if grid[i + a][j + b] == '
                    break
            else:
                print("No")
                exit()

print("Yes")

Solution (Python):
h, w = [int(i) for i in input().split()]
paint = [list(input()) for j in range(h)]
ans = "Yes"

for i in range(h):
    for j in range(w):

        if paint[i][j] == "
            left = paint[i][j-1] == "
            right = paint[i][j+1] == "
            top = paint[i-1][j] == "
            bottom = paint[i+1][j] == "

            if not any([left, right, top, bottom]):
                ans = "No"
                break
    if ans == "No":
        break

print(ans)

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

s = [list('.'*(w+2))]
for _ in range(h):
    s.append(list('.'+input()+'.'))
s.append(list('.'*(w+2)))

for i in range(h):
    for j in range(w):
        if s[i+1][j+1] == '
            if s[i+2][j+1] == '.' and s[i][j+1] == '.' and s[i+1][j+2] == '.' and s[i+1][j] == '.':
                print('No')
                exit()
print('Yes')

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

Solution (Python):
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]
moves = ((1, 0), (0, 1), (0, -1), (-1, 0))
for y in range(H):
    for x in range(W):
        if s[y][x] == '
            flag = True
        else:
            continue
        for dy, dx in moves:
            ny = y + dy
            nx = x + dx
            if 0 <= ny < H and 0 <= nx < W:
                if s[ny][nx] == '
                    flag = False
                    break
        if flag:
            print('No')
            exit()

print('Yes')

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

for h in range(H):
	for w in range(W):
		if S[h][w]=="
			if h>0:
				l.append(S[h-1][w])
			if h<H-1:
				l.append(S[h+1][w])
			if w>0:
				l.append(S[h][w-1])
			if w<W-1:
				l.append(S[h][w+1])
			if "
				flag=1
				break
			l=[]

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

Solution (Python):
H, W = map(int, input().split())
canvas = [[i for i in input()]]
for i in range(H - 1):
    tmp = [i for i in input()]
    canvas.append(tmp)
direction = [[-1, 0], [0, -1], [0, 1], [1, 0]]
for i in range(H):
    for j in range(W):
        if canvas[i][j] == "
            canDraw = False
            for k in direction:
                if (i - k[0] >= 0 and i - k[0] < H) and (j - k[1] >= 0 and j - k[1] < W):
                    if canvas[i - k[0]][j - k[1]] == "
                        canDraw = True
                        break
            if not canDraw:
                print("No")
                exit()
print("Yes")

Solution (Python):
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]=='
            flag=False
print('Yes' if flag else 'No')

Solution (Python):
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] == "
                flg = False

print('Yes' if flg else 'No')

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

s = [list(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):
        can = False
        if s[i][j] == "
            for k in range(4):
                x = i + dx[k]
                y = j + dy[k]
                if 0 <= x <= H - 1 and 0 <= y <= W - 1:
                    if s[x][y] == "
                        can = True
            if can is False:
                print("No")
                exit()

print("Yes")

Solution (Python):
h, w = map(int, input().split())
hw = [list(input()) for _ in range(h)]
num = 0
for i in range(h):
    num+=hw[i].count('

def check(i, j):
    if not (0<=i<h and 0<=j<w):
        return False
    if hw[i][j] == '
        return True
    return False

checked = set()
for i in range(h):
    for j in range(w):
        if hw[i][j] == '
            if (i,j) in checked:
                continue

            exist = False

            for di,dj in [(1,0),(-1,0),(0,1),(0,-1)]:
                ci = i + di
                cj = j + dj
                if check(ci, cj):
                    checked.add((ci,cj))
                    exist = True
            if exist:
                checked.add((i,j))
if num == len(checked):
    print('Yes')
else:
    print('No')

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

Solution (Python):
h, w = map(int, input().split())
a = [input() for _ in range(h)]
flag = True
def check(x, y):
    candidates = []
    if x > 0:
        candidates.append(a[x - 1][y])
    if x < h - 1:
        candidates.append(a[x + 1][y])
    if y > 0:
        candidates.append(a[x][y - 1])
    if y < w - 1:
        candidates.append(a[x][y + 1])
    if '
        return True
    else:
        return False

for i in range(w):
    for j in range(h):
        if a[j][i] == '
            if check(j, i):
                pass
            else:
                flag = False
                break
print('Yes') if flag else print('No')

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

if h == 1 or w == 1:
    print("No")
    exit()

for i in range(h):
    for j in range(w):
        x = 0 
        y = 0 
        if li[i][j] == "
            if i == 0:
                if li[i+1][j] == "
                    x = 1
            elif i == h-1:
                if li[i-1][j] == "
                    x = 1
            else:
                if li[i+1][j] == "
                    x = 1
            if j == 0:
                if li[i][j+1] == "
                    y = 1
            elif j == w-1:
                if li[i][j-1] == "
                    y = 1
            else:
                if li[i][j+1] == "
                    y = 1 

            if x == 0 and y == 0:
                print("No")
                exit()

print("Yes")

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

for i in range(h+2) :
    s[i].insert(0,0)
    s[i].append(0)

around = [[0,1],[0,-1],[1,0],[-1,0]]

for i in range(1,h+1) :
    for j in range(1,w+1) :
        if s[i][j] == '
            ans = False
            for k in range(4) :
                if s[i-around[k][0]][j-around[k][1]] == '
                    ans = True
            if not ans  :
                print('No')
                exit()
print('Yes')

Solution (Python):
h,w=map(int,input().split())
g=[list(input()) for _ in range(h)]
for x in range(h):
    for y in range(w):
        if g[x][y]=="
            k=0
            for i,j in [(1,0),(-1,0),(0,1),(0,-1)]:
                nx=x+i
                ny=y+j
                if nx<0 or nx>=h or ny<0 or ny>=w:
                   continue
                if g[nx][ny]==".":
                    k+=1
            if k==4:
                print("No")
                exit()
print("Yes")

Solution (Python):
h, w = [int(i) for i in input().split()]
s = [input() for j in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            continue
        f = False
        if j > 0:
            if s[i][j-1] == "
                f = True
        if j < w-1:
            if s[i][j+1] == "
                f = True
        if i > 0:
            if s[i-1][j] == "
                f = True
        if i < h-1:
            if s[i+1][j] == "
                f = True
        if not f:
            print("No")
            exit()
print("Yes")

Solution (Python):
import sys

H, W = map(int, input().split())
MAP = [list(input()) for i in range(H)]
gawa = ['.' for i in range(W)]
MAP.append(gawa)
MAP.insert(0, gawa)

for i in range(H+2):
    MAP[i].append('.')
    MAP[i].insert(0, '.')

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 MAP[i][j] == '
            FRAG = 'No'
            for k in range(4):
                if MAP[i + dx[k]][j + dy[k]] == '
                    FRAG = True
            if FRAG != True:
                print(FRAG)
                sys.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(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] == '.':
                print('No')
                exit(0)
print('Yes')
exit(0)

Solution (Python):
H, W = map(int, input().split())
s = []
s.append(['.'] * (W+2))
for i in range(H):
    lis = list('
    s.append(lis)
s.append(['.'] * (W+2))
for i in range(1, H+1):
    for j in range(1, W+1):
        if s[i][j] == '.':
            continue
        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):
n, m = map(int, input().split())
grid = []
for i in range(n):
    grid.append(list(input()))
dr = [0, 0, -1, 1]
dc = [1, -1, 0, 0]
base = True
for i in range(n):
    for j in range(m):
        if grid[i][j] == '
            flag = False
            for k in range(4):
                newx = i + dr[k]
                newy = j + dc[k]
                if newx < 0 or newx >= n or newy < 0 or newy >= m or grid[newx][newy] == '.':
                    continue
                flag = True
            if not flag:
                print('No')
                base = False
                break
    if not base:
        break
if base:
    print('Yes')

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

Solution (Python):
from itertools import product

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


def has_neighbor(_i: int, _j: int) -> bool:
    patterns = [
        (-1, 0), (1, 0), (0, -1), (0, 1),
    ]
    cnt = 0
    for pattern in patterns:
        y, x = _i + pattern[0], _j + pattern[1]
        if y in range(H) and x in range(W):
            c = S[y][x]
            if c == "
                cnt += 1
        else:
            pass
    if cnt:
        return True
    else:
        return False


for i, j in product(range(H), range(W)):
    if S[i][j] == "
        print("No")
        break
else:
    print("Yes")

Solution (Python):
h, w = map(int, input().split())
s = ['.'*(w+2)]
for i in range(h):
  ss = '.' + input() + '.'
  s.append(ss)
s.append('.'*(w+2))
dx = [1,0,-1,0]
dy = [0,1,0,-1]
for i in range(h):
  for j in range(w):
    cnt = 0
    for k in range(4):
      yi = i + dy[k]
      xi = j + dx[k]
      if s[i][j] == '
        cnt += 1
    if cnt == 4:
      print('No')
      exit()

print('Yes')

Solution (Python):
h,w=map(int,input().split())
lista=[]
ans=0
count=0
for i in range(h):
    lista.append(list(input()))
for i in range(h):
    for j in range(w):
        count=0
        if lista[i][j]=="
            if i!=0:
                if lista[i-1][j]=="
                    count=1
            if j!=0:
                if lista[i][j-1]=="
                    count=1
            if i!=h-1:
                if lista[i+1][j]=="
                    count=1
            if j!=w-1:
                if lista[i][j+1]=="
                    count=1
            if count==0:
                ans=1
                break
    if ans==1:
        break
if ans==1:
    print("No")
else:
    print("Yes")

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

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

if sum(list(map(sum, seen))) > 0:
    print('No')
else:
    print('Yes')

Solution (Python):
import sys
h,w=map(int,input().split())
maze=[]
for i in range(h):
    maze.append(list(input()))
for i in range(h):
    for j in range(w):
        if maze[i][j]=="
            flg=False
            for l,m in [(0,1),(1,0),(-1,0),(0,-1)]:
                if 0<=i+l<h and 0<=j+m<w:
                    if maze[i+l][j+m]=="
                        flg=True
            if flg==False:
                print("No")
                sys.exit()
print("Yes")

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def search4(y, x):
    dy = [1, 0, -1, 0]
    dx = [0, 1, 0, -1]
    cnt = 0
    for k in range(4):
        ny = y + dy[k]
        nx = x + dx[k]
        if ny < 0 or H <= ny or nx < 0 or W <= nx:
            continue
        if field[ny][nx] == '
            cnt += 1
    return cnt

H, W = map(int, readline().split())
field = [readline().decode().rstrip() for _ in range(H)]

for y in range(H):
    for x in range(W):
        if field[y][x] == '
            if search4(y, x) == 0:
                print('No')
                exit()
print('Yes')

Solution (Python):
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] == "
      check = []
      if i > 0:
        check.append(s[i-1][j])
      if i < h-1:
        check.append(s[i+1][j])
      if j > 0:
        check.append(s[i][j-1])
      if j < w-1:
        check.append(s[i][j+1])
        
      if not "
        print("No")
        break
  else:
    continue
  break
else:
  print("Yes")

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

for i in range(1, H-1):
  for j in range(1, W-1):
      if G[i][j] == '
        if G[i-1][j] != '
          print('No')
          exit()
        
print('Yes')

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

s = [list(input()) for x in range(H)]

flg = True

for i in range(H):
    for j in range(W):
        if s[i][j] == '
            
            if 0 < i:
                if s[i-1][j] == '
                    flg = False
            
            if 0 < j:
                if s[i][j-1] == '
                    flg = False
            
            if j < W-1:
                if s[i][j+1] == '
                    flg = False
            
            if i < H-1:
                if s[i+1][j] == '
                    flg = False
            if flg:
                print('No')
                exit()
            flg = True
print('Yes')

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

s = [list(input()) for x in range(H)]

flg = True

for i in range(H):
    for j in range(W):
        if s[i][j] == '
            
            if 0 < i:
                if s[i-1][j] == '
                    flg = False
            
            if 0 < j:
                if s[i][j-1] == '
                    flg = False
            
            if j < W-1:
                if s[i][j+1] == '
                    flg = False
            
            if i < H-1:
                if s[i+1][j] == '
                    flg = False
            if flg:
                print('No')
                exit()
            flg = True
print('Yes')

Solution (Python):

h, w = map(int, input().strip().split())
s = []

for _ in range(h):
    temp = input()
    s.append(temp)


def func(height, weight, board):
    for i in range(height):
        for j in range(weight):
            flg = False
            if board[i][j] == '
                if i > 0:
                    if board[i-1][j] == '
                        flg = True
                if j > 0:
                    if board[i][j-1] == '
                        flg = True
                if j < weight - 1:
                    if board[i][j+1] == '
                        flg = True
                if i < height - 1:
                    if board[i+1][j] == '
                        flg = True
                if not flg:
                    print('No')
                    return
    else:
        print('Yes')


func(height=h, weight=w, board=s)