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 _ in range(w + 2)]]

for _ in range(h):
    s_ = ["."]
    s_.extend([x for x in input()])
    s_.append(".")
    s.append(s_)

s.append(["." for _ in range(w + 2)])


for x in range(h):
    for y in range(w):
        target_x = x + 1
        target_y = y + 1
        
        if s[target_x][target_y]  == "
            if s[target_x - 1][target_y] == "
                pass
                
            else:
                
                print("No")
                exit()
print("Yes")

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
h,w=map(int,input().split())
c=[list(input()) for i in range(h)]
dxy=((0,1),(0,-1),(1,0),(-1,0))
def dfs(y,x):
    flag=False
    for dx,dy in dxy:
        nx,ny=x+dx,y+dy
        if 0<=nx<=w-1 and 0<=ny<=h-1 and c[ny][nx]=="
            flag=True
    return flag
for i in range(w):
    for j in range(h):
        if c[j][i]=="
            if not dfs(j,i):
                print("No")
                sys.exit()
print("Yes")

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

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

def func(H,W,a):
  for i in range(H):
    for j in range(W):
      if a[i][j] == '
        if i > 0 and a[i-1][j] == '
          continue
        if j > 0 and a[i][j-1] == '
          continue
        if i < H-1 and a[i+1][j] == '
          continue
        if j < W-1 and a[i][j+1] == '
          continue
        print('No')
        return 0
  print('Yes')
  return 0

func(H,W,a)

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

s = []
s.append(list(("." * (w+1))))

for i in range(h):
    s.append(list(("." + input()+ ".")))

s.append(list(("." * (w+1))))
flag = False

for i in range(h-2):
    for j in range(w-2):
        if s[i+1][j+1] == '
            if s[i+2][j+1] == s[i][j+1] == s[i+1][j+2] == s[i+1][j] == '.':
                flag = True
            else:
                pass
        else:
            pass


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

Solution (Python):
import sys
h, w = (int(i) for i in input().split())
s =[list(input()) for i in range(h)]
flags = []
for i in range(0,h):
    flags.append([0 for i in range(w)])

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

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

for i in range(0,h):
    for j in range(0,w):
        if s[i][j]=="
            if flags[i][j]==0:
                print("No")
                sys.exit()
            else:
                continue

print("Yes")

Solution (Python):
h, w = [int(i) for i in input().split()]
s = [[0 for i in range(w)] for j in range(h)]
s2 = [['.' for i in range(w + 2)] for j in range(h + 2)]

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

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

S=["" for i in range(H+2)]

S[0]="."*(W+2)

for i in range(1,H+1):
    S[i]="."+input()+"."

S[H+1]="."*(W+2)



CHECK=1

for i in range(1,H+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]==".":
                CHECK=0


if CHECK==1:
    print("Yes")
else:
    print("No")

Solution (Python):
H, W = map(int, input().split())
M = []
for i in range(H):
    M.append(list(input()))
answer = 'Yes'
for i in range(H):
    for j in range(W):
        elem = M[i][j]
        if elem == '
            neib = []
            if i != 0:
                neib.append(M[i-1][j])
            if i != H-1:
                neib.append(M[i+1][j])
            if j != 0:
                neib.append(M[i][j-1])
            if j != W-1:
                neib.append(M[i][j+1])
            if '
                answer = 'No'
                break

print(answer)

Solution (Python):
H,W=map(int, raw_input().split())
s=[ list(raw_input()) for i in range(H)]
diff=[(1,0),(-1,0),(0,1),(0,-1)]

for i in range(H):
	for j in range(W):
		if s[i][j]=="
			for dx,dy in diff:
				if i+dx>=0 and j+dy>=0 and i+dx<H and j+dy<W:
					if s[i+dx][j+dy]=="
						break
			else:
				print "No"
				quit()
else:
	print "Yes"

Solution (Python):
H, W = list(map(int, input().split()))
S = [input() for _ in range(H)]
field = [[0 for w in range(W+2)] for h in range(H+2)]

def add(h, w):
    field[h][w + 1] += 1
    field[h + 2][w + 1] += 1
    field[h + 1][w] += 1
    field[h + 1][w + 2] += 1

for h in range(H):
    for w in range(W):
        if S[h][w] == "
            add(h, w)
        else:
            field[h+1][w+1] -= 10
        
res = 0
for l in field[1:H+1]:
    if 0 in l[1:W+1]:
        print("No") 
        break
else:
    print("Yes")

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


newS = ["." * (W+2)]
for rowS in S:
    newS.append("." + rowS + ".")
newS.append("." * (W+2))

for i in range(1, H+1):
    for j in range(1, W+1):
        if newS[i][j] == "
        and newS[i+1][j] != "
            print("No", end = "")
            break
    else:
        continue
    break
else:
    print("Yes", end = "")

Solution (Python):
def solve():
    for i in range(1, H):
        for j in range(1, W):
            if s[i][j] == "
                if s[i + 1][j] == "." and s[i][j + 1] == "." and s[i-1][j] == "." and s[i][j-1] == ".":
                    print("No")
                    return;
    else:
        print("Yes")


H, W = [int(i) for i in input().split()]
s = [["."] * (W + 2)]
for _ in range(H):
    sh = ["."] + list(input()) + ["."]
    s.append(sh)
s.append([["."] * (W + 2)])
solve()

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





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




for x in range(1,h+1):
	for y in range(1,w+1):
		
		if M[x][y]=='.': continue
		
		b=False
		b=b or (M[x-1][y]=='
		b=b or (M[x+1][y]=='
		b=b or (M[x][y-1]=='
		b=b or (M[x][y+1]=='
		
		if b==False:
			print('No')
			exit(0)


print('Yes')

Solution (Python):
H,W = input().split()
H,W = int(H),int(W)
nodes = [list(input()) for i in range(H)]


if H == 1 and W == 1 and nodes[0][0] == ".":
    print("No")
    quit()
if H == 1 and W == 1 and nodes[0][0] == "
    print("Yes")
    quit()


for i in range(H):
    for j in range(W):
        if nodes[i][j] == "
            flag = False
            if i - 1 >= 0:
                if nodes[i-1][j] == "
                    flag = True
            if i + 1 < H:
                if nodes[i+1][j] == "
                    flag = True
            if j - 1 >= 0:
                if nodes[i][j-1] == "
                    flag = True
            if j + 1 < W:
                if nodes[i][j+1] == "
                    flag = True

            if flag == False:
                print("No")
                quit()

print("Yes")

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

Solution (Python):
h,w = map(int,input().split())
s = [list(input()) for i in range(h)]
t = [[(s[i][j] == '.') for j in range(w)] for i in range(h)]
flag = True
for i in range(1,h):
	for j in range(w):
		if s[i-1][j] == '
			t[i-1][j] = True
			t[i][j] = True
for i in range(h):
	for j in range(1,w):
		if s[i][j-1] == '
			t[i][j-1] = True
			t[i][j] = True
for i in range(h):
	for j in range(w):
		if not t[i][j]:
			flag = False
print("Yes" if flag else "No")

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

S = [["." for i in range(W + 2)] for j in range(H + 2)]

for i in range(1, H + 1):
    a = input()
    for j in range(1, W + 1):
        S[i][j] = a[j - 1]


for i in range(1, H + 1):
    for j in range(1, W + 1):
        if S[i][j] == "
            if S[i - 1][j] != "
                NO = 1
                break

if NO == 1:
    print("No")
else:
    print("Yes")

Solution (Python):
H,W = map(int, raw_input().split())
s = [raw_input() for _ in range(H)]
ans = "Yes"
for y in range(H):
  for x in range(W):
    if s[y][x]=="
      ok = False
      for dx,dy in [(-1,0), (1,0), (0,-1), (0,1)]:
        if 0<=x+dx<W and 0<=y+dy<H and s[y+dy][x+dx]=="
          ok = True
      if not ok:
        ans = "No"
print ans

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

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

ans=True
for i in range(H):
  for j in range(W):
    if M[i][j]=='
      if (j+1 < W and M[i][j+1]=='
        continue
      else:
        ans=False
        break
if ans:
  print("Yes")
else:
  print("No")

Solution (Python):
import sys
H,W = map(int,input().split())
listMap = [[i for i in input()] for j in range(H)]
listPatA = [-1,0,0,1]
listPatB = [0,-1,1,0]

def dfs(a,b):
    
    for i in range(4):
        
        A = a + listPatA[i]
        B = b + listPatB[i]

        
        if 0 <= A < H and 0 <= B < W and listMap[A][B] == '
            return True
    
    return False

for i in range(H):
    for j in range(W):
        
        if listMap[i][j] == '
            
            if dfs(i,j) == False:
                print("No")
                sys.exit()

print("Yes")

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

for i in range(h):
    field.append(input())

ans = True

for i in range(h):
    if not ans:
        break
    for j in range(w):
        if field[i][j] == '
            if i != 0 and field[i - 1][j] == '
                continue
            if i != h - 1 and field[i + 1][j] == '
                continue
            if j != 0 and field[i][j - 1] == '
                continue
            if j != w - 1 and field[i][j + 1] == '
                continue
            ans = False
            break

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

Solution (Python):
hw = list(map(int, input().split()))
s = []
for i in range(hw[0]):
    s1 = input()
    s2 = []
    for j in range(len(s1)):
        s2.append(s1[j])
    s.append(s2)

flag = True
if s[0][0] == "
    flag = False
if s[0][hw[1] - 1] == "
    flag = False
if s[hw[0] - 1][0] == "
    flag = False
if s[hw[0] - 1][hw[1] - 1] == "
    flag = False
if hw[0] >= 2:
    for i in range(hw[0] - 2):
        if s[i + 1][0] == "
            flag = False
            break
        if s[i + 1][hw[1] - 1] == "
            flag = False
            break
if hw[1] >= 2:
    for i in range(hw[1] - 2):
        if s[0][i + 1] == "
            flag = False
            break
        if s[hw[0] - 1][i + 1] == "
            flag = False
            break
if hw[0] >= 2 and hw[1] >= 2:
    for i in range(hw[0] - 2):
        for j in range(hw[1] - 2):
            if s[i + 1][j + 1] == "
                flag = False
                break
if flag == False:
    print("No")
else:
    print("Yes")

Solution (Python):
def checkBW(i,j):
    try:
        up = S[i-1][j]
    except:
        up = '.'
    try:
        right = S[i][j+1]
    except:
        right = '.'
    try:
        down = S[i+1][j]
    except:
        down = '.'
    try:
        left = S[i][j-1]
    except:
        left = '.'
    
    if(up == '.' and right == '.' and down == '.' and left == '.'):
        return True
    else:
        return False

H, W = map(int, input().split())
S = []
for i in range(H):
    temp_input = input()
    S.append(temp_input)


for i in range(H):
    for j in range(W):
        if(S[i][j] == '
            
            if(checkBW(i,j)):
                print('No')
                exit()
print('Yes')

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

flag = False
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            continue
        if i - 1 >= 0:
            if s[i - 1][j] == '
                continue
        if j - 1 >= 0:
            if s[i][j - 1] == '
                continue
        if i + 1 < h:
            if s[i + 1][j] == '
                continue
        if j + 1 < w:
            if s[i][j + 1] == '
                continue
        flag = True
        break
    if flag:
        break

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

Solution (Python):
import numpy as np
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
s = np.array(s)
out = "Yes"
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            continue
        if i == 0 and j == 0:
            up = s[i][j]
            down = s[i + 1][j]
            left = s[i][j]
            right = s[i][j + 1]
        elif i == 0 and j == w-1:
            up = s[i][j]
            down = s[i + 1][j]
            left = s[i][j - 1]
            right = s[i][j]
        elif i == h-1 and j == 0:
            up = s[i - 1][j]
            down = s[i][j]
            left = s[i][j]
            right = s[i][j + 1]
        elif i == h-1 and j == w-1:
            up = s[i - 1][j]
            down = s[i][j]
            left = s[i][j - 1]
            right = s[i][j]
        elif i == 0 and j != 0 and j != w-1:
            up = s[i][j]
            down = s[i + 1][j]
            left = s[i][j - 1]
            right = s[i][j + 1]
        elif i == h-1 and j != 0 and j != w-1:
            up = s[i - 1][j]
            down = s[i][j]
            left = s[i][j - 1]
            right = s[i][j + 1]
        elif j == 0 and i !=  0 and i != h-1:
            up = s[i - 1][j]
            down = s[i + 1][j]
            left = s[i][j]
            right = s[i][j + 1]
        elif j == w-1 and i != 0 and i!= h-1:
            up = s[i - 1][j]
            down = s[i + 1][j]
            left = s[i][j - 1]
            right = s[i][j]
        else:
            up = s[i-1][j]
            down = s[i+1][j]
            left = s[i][j-1]
            right = s[i][j+1]
        if s[i][j] != up and s[i][j] != down and s[i][j] != left and s[i][j] != right:
            out = "No"
print(out)

Solution (Python):
import numpy as np
na = np.array

def ii():
    return int(input())


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


def lvi(N):
    l = []
    for _ in range(N):
        l.append(ii())
    return l


def lv(N):
    l = []
    for _ in range(N):
        l.append(input())
    return l


def yn(b):
    if b:
        print('Yes')
    else:
        print('No')


def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1


def ok(S, i, j):
    try:
        if S[i+1][j] == '
            return True
    except:
        pass
    try:
        if S[i-1][j] == '
            return True
    except:
        pass
    try:
        if S[i][j+1] == '
            return True
    except:
        pass
    try:
        if S[i][j-1] == '
            return True
    except:
        pass

    return False


def C():

    H, W = lii()
    S = []
    for _ in range(H):
        S.append(input())

    for i, l in enumerate(S):
        for j in range(len(l)):
            if S[i][j] == '
                if not ok(S, i, j):
                    return False

    return True


if __name__ == '__main__':
    yn(C())

Solution (Python):
h,w=[int(i) for i in input().split()]
s=[]
count=0




c_org = [ [ 0 if c_org == "
 



for i in range(h):
    c_org[i].append( -1)
    c_org[i].insert(0,-1)
    count=count+c_org[i].count(9999)
c_plus=[-1 for i in range(w+2)]
 

c=[]
c.append(c_plus)
for i in range(h):
    c.append(c_org[i])
c.append(c_plus)


aaaaa=0
for i in range(h):
  for j in range(w):
     if c[i+1][j+1]==0:
         if c[i+1][j+2]==0 or c[i+2][j+1]==0 or c[i][j+1]==0 or c[i+1][j]==0:
           pass
         else:

           aaaaa=1
 





if aaaaa==1:
    print("No")
else:
    print("Yes")

Solution (Python):
h,w=map(int,input().split())
arr=[]
for i in range(h):
	s=str(input())
	arr.append(s)
if(h==1 and w==1):
	if(arr[0][0]=='.'):
		print("Yes")
	else:
		print("No")
elif(h==1 and w>1):
	if(arr[0][0]=='
		print("No")
	elif(arr[0][w-1]=='
		print("No")
	else:
		for j in range(1,w-1):
			if(arr[0][j]=='
				if(arr[0][j-1]!='
					print("No")
					flag=1
					break
		if(flag==0):
			print("Yes")

elif(h>1 and w==1):
	if(arr[0][0]=='
		print("No")
	elif(arr[h-1][0]=='
		print("No")
	else:
		flag=0
		for j in range(1,h-1):
			if(arr[j][0]=='
				if(arr[j-1][0]!='
					print("No")
					flag=1
					break
		if(flag==0):
			print("Yes")
else:
	flag=0
	for j in range(1,w-1):
			if(arr[0][j]=='
				if(arr[0][j-1]!='
					print("No")
					flag=1
					break
	if(flag==0):
		for j in range(1,w-1):
			if(arr[h-1][j]=='
				if(arr[h-1][j-1]!='
					print("No")
					flag=1
					break
	if(flag==0):
		for j in range(1,h-1):
			if(arr[j][0]=='
				if(arr[j-1][0]!='
					print("No")
					flag=1
					break
	if(flag==0):
		for j in range(1,h-1):
			if(arr[j][w-1]=='
				if(arr[j-1][w-1]!='
					print("No")
					flag=1
					break
	if(flag==0):				
		for j in range(1,h-1):
			for k in range(1,w-1):
				if(arr[j][k]=='
					if(arr[j-1][k]!='
						print("No")
						flag=1
						break
			if(flag==1):
				break
	if(flag==0):
		print("Yes")

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



dx = [1, 0, -1, 0]
dy = [0, -1, 0, 1]
import sys
for i in range(h):
    for j in range(w):
        if ma[i][j] == '
            flag = False
            for x, y in zip(dx, dy):
                if j + x < 0 or i + y < 0 or j + x >= w or i + y >= h:
                    continue

                if ma[i + y][j + x] == '
                    flag = True

            if flag == False:
                print('No')
                sys.exit(0)
print('Yes')
sys.exit(0)

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

def is_check():
    for i in range(h):
        for j in range(w):
            if s[i][j] == '
                return 'No'
    return 'Yes'

print(is_check())

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

flag = True

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:
                flag = False
                break
    if flag == False:
        break

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

Solution (Python):
import numpy as np
H, W = map(int, input().split())
lines = [input() for i in range(H)]
grid = np.zeros([H, W])
for i in range(H):
    for ii in range(W):
        if lines[i][ii] == '
            grid[i, ii] = 1
flag = True
for i in range(H):
    for ii in range(W):
        if grid[i, ii] == 1:
            if i == 0:
                if ii == 0:
                    a = grid[i, ii+1] + grid[i+1, ii]
                elif ii == W-1:
                    a = grid[i, ii-1] + grid[i+1, ii]
                else:
                    a = grid[i, ii-1] + grid[i, ii+1] + grid[i+1, ii]
            elif i == H-1:
                if ii == 0:
                    a = grid[i, ii+1] + grid[i-1, ii]
                elif ii == W-1:
                    a = grid[i, ii-1] + grid[i-1, ii]
                else:
                    a = grid[i, ii-1] + grid[i, ii+1] + grid[i-1, ii]
            else:                
                if ii == 0:
                    a = grid[i, ii+1] + grid[i+1, ii] + grid[i-1, ii]
                elif ii == W-1:
                    a = grid[i, ii-1] + grid[i+1, ii] + grid[i-1, ii]
                else:
                    a = grid[i, ii-1] + grid[i, ii+1] + grid[i+1, ii] + grid[i-1, ii]
            if a == 0:
                flag = False
if flag:
    print('Yes')
else:
    print('No')

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

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

for j in range(h):
    for k in range(w):
        cnt = 0
        if c[j][k] == "
            if j != 0:
                if c[j-1][k] == "
                    cnt += 1
            if k != 0:
                if c[j][k-1] == "
                    cnt += 1
            if j != h - 1:
                if c[j+1][k] == "
                    cnt += 1
            if k != w - 1:
                if c[j][k+1] == "
                    cnt += 1

            if cnt == 0:
                print("No")
                break

    else:
        continue
    break

else:
    print("Yes")

Solution (Python):
def main():
    h, w = map(int, input().split())
    m = []

    for _ in range(h):
        line = input()
        m.append(line)

    if judge_map(m):
        print('Yes')
    else:
        print('No')

def judge_map(m):
    for i in range(len(m)):
        for j in range(len(m[i])):
            if not judge(m, i, j):
                return False
    return True

def judge(m, i, j):
    if m[i][j] == '.':
        return True
    
    if i - 1 >= 0 and m[i - 1][j] == '
        return True
    
    if i + 1 < len(m) and m[i + 1][j] == '
        return True
    
    if j - 1 >= 0 and m[i][j-1] == '
        return True
    
    if j + 1 < len(m[i]) and m[i][j + 1] == '
        return True
    
    return False


main()

Solution (Python):
H,W=map(int,input().split())
s = [['.' for i in range(W+2)] for j in range(H+2)]
f=0
for i in range(H):
 s[i+1] = ['.'] + list(input()) + ['.']
for i in range(H+2):
 if f == 0:
  for j in range(W+2):
   if s[i][j] == '
    if s[i-1][j] == '.' and s[i+1][j] == '.' and s[i][j-1] == '.' and s[i][j+1] == '.':
     f = 1
     print('No')
     break
if f == 0:
 print('Yes')

Solution (Python):
h,w = map(int,input().split())
s = []
for i in range(h):
	stemp = list(input())
	s.append(stemp)
check = True
for i in range(h):
	for k in range(w):
		if s[i][k] == '
			counter = 0
			if k+1 < w and s[i][k+1] == '
				counter += 1
			if 0 <= k-1 and s[i][k-1] == '
				counter += 1
			if i+1 < h and s[i+1][k] == '
				counter += 1
			if 0 <= i-1 and s[i-1][k] == '
				counter += 1
			if counter == 0:
				check = False
if check:
	print('Yes')
else:
	print('No')

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

ans = "Yes"
for i in range(h):
    for j in range(w):
        if s[i][j] == '
            ok = False
            if 0 < i and s[i - 1][j] == '
                ok = True
            if i + 1 < h and s[i + 1][j] == '
                ok = True
            if 0 < j and s[i][j - 1] == '
                ok = True
            if j + 1 < w and s[i][j + 1] == '
                ok = True
            if not ok:
                ans = "No"
print(ans)

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

def search(y,x):
    if s[y][x] != "
        return True
    if s[y][x] == "
        for dy,dx in ((1,0),(-1,0),(0,1),(0,-1)):
            ny,nx = (y+dy,x+dx)
            if 0 <= ny <= h-1 and 0 <= nx <= w-1:
                if s[ny][nx] == "
                    return True
    return False


for i in range(h):
    for j in range(w):
        if search(i,j) == False:
            print("No")
            exit()
print("Yes")

Solution (Python):
import sys

def check(i,j):
    delta = [(-1,0), (1,0), (0,1), (0,-1)]
    for d in delta:
        ni = i + d[0]
        nj = j + d[1]
        if (ni >= 0 and ni < H and nj >= 0 and nj < W):
            if (m[ni][nj] == '
                return True
        else:
            continue
    return False
        
H,W = list(map(int, input().split()))
m = []
for i in range(H):
    l = str(input())
    m.append(l)

for i in range(H):
    for j in range(W):
        if m[i][j] == '
            print('No')
            sys.exit()
print('Yes')

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

    for i in range(H):
        for j in range(W):
            if s[i][j] == ".":
                continue
            elif i==0:
                if j==0:
                    if s[i+1][j]=="." and s[i][j+1]==".":
                        return "No"
                elif j==W-1:
                    if s[i+1][j]=="." and s[i][j-1]==".":
                        return "No"
                else:
                    if s[i][j+1]=="." and s[i+1][j]=="." and s[i][j-1]==".":
                        return "No"
            elif i==H-1:
                if j==0:
                    if s[i-1][j]=="." and s[i][j+1]==".":
                        return "No"
                elif j==W-1:
                    if s[i-1][j]=="." and s[i][j-1]==".":
                        return "No"
                else:
                    if s[i-1][j]=="." and s[i][j-1]=="." and s[i][j+1]==".":
                        return "No"
            elif j==0:
                if s[i+1][j]=="." and s[i-1][j]=="." and s[i][j+1]==".":
                    return "No"
            elif j==W-1:
                if s[i+1][j]=="." and s[i-1][j]=="." and s[i][j-1]==".":
                    return "No"
            else:
                if s[i+1][j]=="." and s[i-1][j]=="." and s[i][j-1]=="." and s[i][j+1]==".":
                    return "No"
    return "Yes"

if __name__ == '__main__':
    print(main())

Solution (Python):
H, W = map(int, input().split())
A = []
for i in range(H):
    B = input()
    C = []
    for j in B:
        C.append(j)
    A.append(C)

flag = 0
for k in range(H):
    if flag == 1:
        break
    for l in range(W):
        if A[k][l] == "
            if A[max(0, k-1)][l] == A[k][max(0, l-1)] == A[min(H-1, k+1)][l] == A[k][min(W-1, l+1)] == ".":
                flag = 1
                break

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

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

for x in range(h):
  for y in range(w):
    if s[x][y] == '
      counter = 0
      direction = 4
      t = [-1, 1, 0, 0, 0, 0, -1, 1]
      for i in range(4):
        try:
          counter += (s[x+t[i]][y+t[i+4]] != '
        except:
          direction -= 1
      if counter == direction:
        print('No')
        exit(0)
print('Yes')

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

result = True

def check(i, j):
  if board[i][j] == '.':
    return True
  
  if i == 0:
    if j == 0:
      if board[i][j + 1] == '.' and board[i + 1][j] == '.':
        return False
    elif j == w - 1:
      if board[i][j - 1] == '.' and board[i + 1][j] == '.':
        return False
    else:
      if board[i][j - 1] == '.' and board[i][j + 1] == '.' and board[i + 1][j] == '.':
        return False
  elif i == h - 1:
    if j == 0:
      if board[i][j + 1] == '.' and board[i - 1][j] == '.':
        return False
    elif j == w - 1:
      if board[i][j - 1] == '.' and board[i - 1][j] == '.':
        return False
    else:
      if board[i][j - 1] == '.' and board[i][j + 1] == '.' and board[i - 1][j] == '.':
        return False
  else:
    if j == 0:
      if board[i][j + 1] == '.' and board[i - 1][j] == '.' and board[i + 1][j] == '.':
        return False
    elif j == w - 1:
      if board[i][j - 1] == '.' and board[i - 1][j] == '.' and board[i + 1][j] == '.':
        return False
    else:
      if board[i][j - 1] == '.' and board[i][j + 1] == '.' and board[i - 1][j] == '.' and board[i + 1][j] == '.':
        return False

  return True

for i in range(h):
  for j in range(w):
    result = check(i, j)
    if not result:
      break
  if not result:
    break

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

Solution (Python):


neighbor_i = [-1, 0, 1, 0]
neighbor_j = [0, -1, 0, 1]

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


def can_draw(l, target_i, target_j):
    for i, j in zip(neighbor_i, neighbor_j):
        if target_i + i < 0 or target_j < 0:
            continue
        if target_i + i >= H or target_j + j >= W:
            continue
        if l[target_i + i][target_j + j] == '
            return True

    return False


data = []
for i in range(H):
    raw = list(str(input()))
    data.append(raw)





ok = True
for i in range(H):
    for j in range(W):
        if data[i][j] == '
            if not can_draw(data, i, j):
                ok = False
                break
    if not ok:
        break

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

Solution (Python):
import sys

h, w=(int(word) for word in input().split())
canvas=[["." for wi in range(w+2)] for hi in range(h+2)]
for hi in range(h):
    l=input()
    for wi in range(w):
        canvas[hi+1][wi+1]=l[wi]
ds=[(-1, 0), (1, 0), (0, -1), (0, 1)]
for hi in range(1, h+1):
    for wi in range(1, w+1):
        if canvas[hi][wi]==".": continue
        conts=False
        for d in ds:
            if canvas[hi+d[0]][wi+d[1]]=="
                conts=True
                break
        if not conts:
            print("No")
            sys.exit()
print("Yes")

Solution (Python):
h,w = map(int,raw_input().split())
s = []
a = True
for i in range(h):
    s.append(raw_input())
for i in range(h):
    for j in range(w):
        if s[i][j] == '
            if i - 1 >= 0 and s[i-1][j] == '
                continue
            if i + 1 < h and s[i+1][j] == "
                continue
            if j - 1 >= 0 and s[i][j-1] == '
                continue
            if j + 1 < w and s[i][j+1] == '
                continue
            a = False
if a == True:
    print 'Yes'
else:
    print 'No'