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 = [["."]+list(input())+["."] for _ in range(h)]
s.insert(0, ["." for _ in range(w+2)])
s.append(["." for _ 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][j+1]=="
                ans = "No"
print(ans)

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

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

Solution (Python):
if __name__ == "__main__":
    H, W = map(int, input().split())
    s = []
    for i in range(H):
        s.append(input())
    
    """
    
    . white
    """
    
    black = "
    white = "."
    
    ans = "Yes"
    break_flag = False
    for i in range(H):
        for j in range(W):
            if s[i][j] == black:
                above = False
                under = False
                left = False
                right = False
                
                if 0 < i:
                    above = (s[i - 1][j] == black)
                if i < H - 1:
                    under = (s[i + 1][j] == black)
                if 0 < j:
                    left = (s[i][j - 1] == black)
                if j < W - 1:
                    right = (s[i][j + 1] == black)
                
                if not (above or under or left or right):
                    break_flag = True
                    ans = "No"
                    
                    
            
            if break_flag:
                break
            
        if break_flag:
            break
    
    print(ans)

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

Solution (Python):

h, w = map(int,(input().split()))
s= [[0]*(w+2)]*(h+2)
ans= 'Yes'
for i in range(1,h+1):
        s[i] = [0] + list(input()) + [0]

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

print(ans)

Solution (Python):
H, W=map (int, input().split(' '))
z=[]

for i in range(H):
    z.append(list(str(input())))


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

for h in range(H):
    for w in range(W):
        if z[h][w] == '
            p=0
            for i in range(4):
                x = w + dx[i]
                y = h + dy[i]

                if x < 0 or y <0 or x > W-1 or y >H-1:
                    continue

                if z[y][x]=="
                    p+=1
            if p==0:
                print('No')
                exit()

print('Yes')

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

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if s[i][j] == '
            if all(s[i + dx][j + dy] == '.' for dx, dy in direction):
                print('No')
                exit()

print('Yes')

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


h, w = LI()
grid = SR(h)
que = deque()


def dfs():
    for y in range(h):
        for x in range(w):
            if grid[y][x] == '
                for i, j in [(0,1),(1,0),(-1,0),(0,-1)]:
                    if 0<=y+i<h and 0<=x+j<w and grid[y+i][x+j] == '
                        break
                else:
                    return 'No'
    return 'Yes'



print(dfs())

Solution (Python):
h,w=map(int,input().split())
da=[input() for i in range(h)]
for i in range(h):
    da[i]='.'+da[i]+'.'
sample='.'*(w+2)
da.insert(0,sample)
da.append(da)
ju=False
for i in range(h):
    for j in range(w):
        if(da[i+1][j+1]=='
            if(not(da[i][j+1]=='
                print('No')
                ju=True
                break
    if(ju):
        break
if(not ju):
    print('Yes')

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

for i in range(H + 2):
    s[i] = [0] + s[i] + [0]

for i in range(H):
    for j in range(W):
        if s[i + 1][j + 1] == '
            if s[i][j + 1] != '
                print('No')
                exit()
        else:
            continue
print('Yes')

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

dx=[0,1,0,-1]
dy=[1,0,-1,0]
ans=True
for i in range(h):
    for j in range(w):
        if s[i][j]=='
            ans=False
            for k in range(4):
                nx = i+dx[k]
                ny = j+dy[k]
                if nx>=0 and nx <h and ny>=0 and ny<w and s[nx][ny]=='
                    ans = True
                    break
            if ans ==False:
                print('No')
                exit()
if ans:
    print('Yes')

Solution (Python):
H, W = map(int,input().split())
s = [list(input()) for _ in range(H)]
for i in range(H):
    s[i] = [0] + s[i] + [0]
s = [[0]*(W+2)] + s + [[0]*(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] == '
                continue
            else:
                print('No')
                exit()
print('Yes')

Solution (Python):
import sys
H,W = map(int,input().split())
S = ["."*(W+2)]
for _ in range(H):
    s = input()
    s = "."+s+"."
    S.append(s)
S.append("."*(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] == S[i-1][j] == S[i][j+1] == S[i][j-1] == ".":
                print("No")
                sys.exit()
print("Yes")

Solution (Python):
h, w = map(int,(input().split()))
s= [[0]*(w+2)]*(h+2)
ans= 'Yes'
for i in range(1,h+1):
        s[i] = [0] + list(input()) + [0]

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

print(ans)

Solution (Python):
def check():
    H, W = [int(i) for i in input().split(' ')]
    a = [input() for _ in range(H)]
    
    
    for h in range(H):
        for w in range(W):
            flag = [0,0,0,0]
            if a[h][w] == '
                if h != 0:
                    if a[h-1][w] != '
                        flag[0] = 1
                else:
                    flag[0] = 1
                if h != H-1:
                    if a[h+1][w] != '
                        flag[1] = 1
                else:
                    flag[1] = 1
                if w != 0:
                    if a[h][w-1] != '
                        flag[2] = 1
                else:
                    flag[2] = 1
                if w != W-1:
                    if a[h][w+1] != '
                        flag[3] = 1
                else:
                    flag[3] = 1 
            if sum(flag) == 4:
                    return 'No'
                    
    return 'Yes'
print(check())

Solution (Python):
import sys

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] == '
      for x, y in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
        if S[i+x][j+y] == '
          break
      else:
        print('No')
        sys.exit()
else:
  print('Yes')

Solution (Python):
def solve():
    H,W = list(map(int, input().split()))
    S = ['.'*(W+2)]+['.'+input()+'.' for _ in range(H)]+['.'*(W+2)]
    result = '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] == '
                    result = 'No'
                    break
    
    print( result )
    
solve()

Solution (Python):

from itertools import product


def resolve():
    h,w=map(int,input().split())
    A=['.'+input()+'.' for _ in range(h)]
    A=['.'*(w+2)]+A+['.'*(w+2)]
    flag = 1

    for i,j in product(range(1,h+1),range(1,w+1)):
        if A[i][j]=='
            flag = min(flag,A[i-1][j]=='

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

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):

from itertools import product


def resolve():
    h,w=map(int,input().split())
    A=['.'+input()+'.' for _ in range(h)]
    A=['.'*(w+2)]+A+['.'*(w+2)]
    flag = 1

    for i,j in product(range(1,h+2),range(1,w+2)):
        if A[i][j]=='
            flag = min(flag,A[i-1][j]=='

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

Solution (Python):
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def solve():
  h,w = (int(i) for i in input().split())
  maze = ["."*(w+2)]
  for i in range(h):
    maze.append("." + input()+ ".")
  maze.append("."*(w+2))
  start = deque([])

  for i in range(h):
    for j in range(w):
      if maze[i][j] == "
        start.append((i,j))

  while start:
      height,width = start.popleft()
      isblacknear = False
      d = [(1,0),(0,1),(-1,0),(0,-1)]
      for dy,dx in d:
        nh = height + dy
        nx = width + dx
        if maze[nh][nx] == "
          isblacknear = True
          break
      if not isblacknear:
        print("No")
        exit()
  print("Yes")
        
      
      
solve()

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

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

temp = "0" * (w+2)

s = [temp]

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

s.append(temp)

for i in range(h+2):
    for j in range(w+2):
        flag = False
        if s[i][j] == "
            if s[i-1][j] == "
                flag = True
            if not flag:
                print("No")
                exit()

print("Yes")

Solution (Python):
from sys import exit
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] == '.':
      continue
    if i > 0 and s[i - 1][j] == '
      continue
    if i < h - 1 and s[i + 1][j] == '
      continue
    if j > 0 and s[i][j - 1] == '
      continue
    if j < w - 1 and s[i][j + 1] == '
      continue
    print('No')
    exit()
print('Yes')

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

m = []
for i in range(H):
    m.append(list(input().strip()))

for h in range(H):
    for w in range(W):
        if m[h][w] != '
            continue
        
        if w - 1 >= 0:
            if m[h][w - 1] == '
                continue
        
        if w + 1 < W:
            if m[h][w + 1] == '
                continue
        
        if h - 1 >= 0:
            if m[h - 1][w] == '
                continue
        
        if h + 1 < H:
            if m[h + 1][w] == '
                continue
        print('No')
        exit()

print('Yes')

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    h, w = list(map(int, input().rstrip('\n').split()))
    a = [list(str(input().rstrip('\n'))) for _ in range(h)]
    for i in range(h):
        for j in range(w):
            if a[i][j] == "
                cnt = 0
                if 0 <= i - 1 < h and a[i-1][j] == "
                    cnt += 1
                if 0 <= i + 1 < h and a[i+1][j] == "
                    cnt += 1
                if 0 <= j - 1 < w and a[i][j-1] == "
                    cnt += 1
                if 0 <= j + 1 < w and a[i][j+1] == "
                    cnt += 1
                if cnt == 0:
                    print("No")
                    exit()
    print("Yes")


if __name__ == '__main__':
    slove()

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

s = ["." * (w + 2)]
for i in range(h):
    s.append("." + input() + ".")
s.append("." * (w + 2))

ans = "Yes"
for h_i in range(1, h + 1):
    for w_i in range(1, w + 1):
        if s[h_i][w_i] == "
            if s[h_i-1][w_i] == "." and s[h_i+1][w_i] == "." and s[h_i][w_i-1] == "." and s[h_i][w_i+1] == ".":
                ans = "No"

print(ans)

Solution (Python):




h, w = map(int, input().split())
s = []
waku = "a"*(w+2)
s.append(waku)
for i in range(h):
    kari = "a" + input() + "a"
    s.append(kari)
s.append(waku)


k = [-1,0,1,0]
l = [0,-1,0,1]



flag = 1
for i in range(1,h + 1):
    for j in range(1,w+1):
        count = 0
        if s[i][j] == "
            for m in range(4):
                if s[i+k[m]][j+l[m]] == "
                    count = 1 
            if count == 0:
                flag = 0 
if flag == 0:
    print("No")
if flag == 1:
    print("Yes")

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

for h_i in range(h):
    for w_i in range(w):
        if canpas[h_i][w_i] == '
            if w_i - 1 < 0:
                c1 = False
            else:
                c1 = canpas[h_i][w_i-1] == '

            if h_i - 1 < 0:
                c2 = False
            else:
                c2 = canpas[h_i-1][w_i] == '

            if h_i + 1 >= h:
                c3 = False
            else:
                c3 = canpas[h_i+1][w_i] == '

            if w_i + 1 >= w:
                c4 = False
            else:
                c4 = canpas[h_i][w_i+1] == '

            if c1 or c2 or c3 or c4:
                continue
            else:
                print('No')
                break
    else:
        continue
    break
else:
    print('Yes')

Solution (Python):
"""考え方
上下左右のいずれか隣接するマスが黒である必要がある。
つまり黒マスが1つだけポツンと存在した場合はNGとなる。

横チェック、縦チェック、の2つに分断して確認を行う。
"""

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

list_matu = []

for h in range(H):
  list_matu.append(list(input()))



ng_matu=[]
for h in range(H): 
  for w in range(1,W-1): 
    target = list_matu[h][w]
    target_left = list_matu[h][w-1]
    target_right = list_matu[h][w+1]
    
    if target=='
      if (target_left != '
        ng_matu.append([h,w])



for w in range(W):
  for h in range(1,H-1):
    target = list_matu[h][w]
    target_over = list_matu[h+1][w]
    target_under = list_matu[h-1][w]
    
    if target=='
      if (target_over != '
        if [h,w] in ng_matu:
          print('No')
          exit()


print('Yes')

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

for i in range(0,H):
    Slist.append(str(input()))
    HWlist.append(list(Slist[i]))

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

print("Yes")

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

    check = [[False] * W for i in range(H)]

    count = 0
    for i in range(H):
        for j in range(W):
            if not check[i][j]:
                if board[i][j] == ".":
                    check[i][j] = True
                    count += 1
                else:
                    ok = False
                    for tx, ty in [(i+1, j), (i-1, j), (i, j+1), (i, j-1)]:
                        if 0 <= tx and tx < H and 0 <= ty and ty < W:
                            if board[tx][ty] == "
                                ok = True
                                if not check[tx][ty]:
                                    check[tx][ty] = True
                                    count += 1
                    if ok:
                        check[i][j] = True
                        count += 1
    if count == H*W:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Solution (Python):
h, w = map(int, input().split())
table = [[False for _ in range(w + 2)]]
for i in range(h):
    row = [False]
    for c in input():
        row.append(c == '
    row.append(False)
    table.append(row)
table.append([False for _ in range(w + 2)])

ok = True
for i in range(1, h + 1):
    for j in range(1, w + 1):
        if table[i][j]:
            ok = ok and (table[i][j - 1] or table[i][j + 1] or table[i - 1][j]
                         or table[i + 1][j])
        if not ok:
            break
    if not ok:
        break
if ok:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
import math
from fractions import gcd





def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""


 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())


 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""



H, W =  map(int, sys.stdin.readline().split())
L =  [list(list(sys.stdin.readline().rstrip())) for i in range(H)]

PL = [["0"] + l + ["0"] for l in L]

t = ["0"] * (W + 2)

PL.insert(0, t)
PL.append(t)

for i in range(1, H + 1):
    for j in range(1, W + 1):
        if PL[i][j] == "
            if PL[i][j - 1] == "
                continue
            else:
                print("No")
                exit()

print("Yes")

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

for i in range(H):
  for j in range(W):
    if G[i][j] == '
      if i == 0:
        if j == 0:
          if G[0][1] == '.' and G[0][0] == '.':
            print("No")
            exit()
        if 0<j<W-1:
          if G[0][j-1] == '.' and G[0][j+1] == '.' and G[1][j] == '.':
            print("No")
            exit()
        if j == W-1:
          if G[0][j-1] == '.' and G[1][j] == '.':
            print("No")
            exit()
      elif 0<i<H-1:
        if j==0:
          if G[i-1][j] == '.' and G[i][1] == '.' and G[i+1][0] == '.':
            print("No")
            exit()
        elif 0<j<W-1:
          if G[i-1][j] == '.' and G[i][j-1] == '.' and G[i][j+1] == '.' and G[i+1][j] == '.':
            print("No")
            exit()
        elif j == W-1:
          if G[i-1][j] == '.' and G[i][j-1] == '.' and G[i+1][j] == '.':
            print("No")
            exit()
      elif i == H-1:
        if j == 0:
          if G[H-2][j] == '.' and G[H-1][j+1] == '.':
            print("No")
            exit()
        elif 0<j<W-1:
          if G[i-1][j] == '.' and G[i][j-1] == '.' and G[i][j+1] == '.':
            print("No")
            exit()
        elif j == W-1:
          if G[i-1][j] == '.' and G[i][j-1] == '.':
            print("No")
            exit()
            
print("Yes")

Solution (Python):


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

for i in range(h):
    s[i] = list(input())


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

result = True

for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            continue
        else:
            can_drow = False
            for d in range(len(dx)):
                x = j + dx[d]
                y = i + dy[d]

                if not 0 <= x < w:
                    continue
                if not 0 <= y < h:
                    continue
                if s[y][x] == "
                    can_drow = True
                    break
            if not can_drow:
                result = False

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

Solution (Python):
import sys
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == "
            print("No")
            sys.exit()
print("Yes")

Solution (Python):
import sys
h,w = map(int,input().split())
s = ['']*h
for i in range(h):
  s[i] = input()
 
black = False
for i in range(h):
  for j in range(w):
    if s[i][j] == '
      if j != w - 1:
        if s[i][j + 1] == '
          continue
      if  j != 0:
        if s[i][j - 1] == '
          continue
      if i != h - 1:
        if s[i + 1][j] == '
          continue
      if i != 0:
        if s[i - 1][j] == '
          continue
      print('No')
      sys.exit()       
print('Yes')

Solution (Python):
import sys

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

def judge(f, i, j):
	np = [[i-1,j], [i+1,j], [i,j-1], [i,j+1]]
	for p in np:
		if 0 <= p[0] <= H-1 and 0 <= p[1] <= W-1 and f[p[0]][p[1]] =="
			return 0
	return 1


for i in range(H):
	for j in range(W):
		if canv[i][j] == "
			if judge(canv, i, j) == 1:
				print("No")
				sys.exit()

print("Yes")

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

h, w = na()
li = []
pad = ""
for i in range(w+2):
    pad += "."
li.append(pad)
for i in range(h):
    li.append("." + input() + ".")
li.append(pad)
ans = "Yes"
flag = False
for y in range(1, h+1):
    for x in range(1, w+1):
        if li[y][x] == "
            if li[y-1][x] == "
                continue
            else:
                ans = "No"
                flag = True
                break
    if flag:
        break
print(ans)

Solution (Python):
H, W = map(int, input().split())
S = []
for i in range(H):
  ss = input()
  S.append(ss)
ok = True
for i in range(H):
  for j in range(W):
    if S[i][j] == "
      ok2 = False
      if j-1 >= 0 and S[i][j-1] == "
        ok2 = True
      if i-1 >= 0 and S[i-1][j] == "
        ok2 = True
      if j+1 < W and S[i][j+1] == "
        ok2 = True
      if i+1 < H and S[i+1][j] == "
        ok2 = True
      if not(ok2):
        ok = False
if ok:
  print("Yes")
else:
  print("No")

Solution (Python):

import sys
import math
from collections import defaultdict


sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]


mod = 10**9 + 7


def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))



from itertools import product

H,W = II()
s = [list(map(str, input())) for _ in range(H)]

def neighbor(i,j):
    if H==1:
        x = []
    else:
        if i==0:
            x = [1]
        elif i==H-1:
            x = [H-2]
        else:
            x = [i-1,i+1]
    if W==1:
        y = []
    else:
        if j==0:
            y = [1]
        elif j==W-1:
            y = [W-2]
        else:
            y = [j-1,j+1]
    return  list(product(x,[j])) + list(product([i],y))  

for i in range(H):
    for j in range(W):
        if s[i][j] == '
            flag = True
            a = neighbor(i,j)
            for k in a:
                if s[k[0]][k[1]] == '
                    flag = False
                    break
            if flag:
                print('No')
                exit()

print('Yes')

Solution (Python):

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

S = []
for i in range(H):
    s = list(input())
    S.append(s)
f = "Yes"
for i in range(H):
    for j in range(W):
        if S[i][j] == "
            r = 0
            if i != 0:
                if S[i - 1][j] == "
                    r += 1
            if j != 0:
                if S[i][j - 1] == "
                    r += 1
            if i + 1 != H:
                if S[i + 1][j] == "
                    r += 1
            if j + 1 != W:
                if S[i][j + 1] == "
                    r += 1
            if r == 0:
                f = "No"
                break
    if f == "No":
        break

print(f)

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

ok = 1
for i, ss in enumerate(sss) :
    for j, s in enumerate(ss) :
        if s == "
            okness = 0
            try : 
                if ss[j-1] == "
                    okness = 1
            except : pass
            try : 
                if ss[j+1] == "
                    okness = 1
            except : pass
            try : 
                if sss[i-1][j] == "
                    okness = 1
            except : pass
            try : 
                if sss[i+1][j] == "
                    okness = 1
            except : pass
            ok *= okness
print(" YNeos"[ok::2])

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

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 = True

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

Solution (Python):
h, w = list(map(int, input().split()))
s = [input() for _ in range(h)]
move = [(-1, 0), (1, 0), (0, -1), (0, 1)]
flag = 1
for i in range(h):
    for j in range(w):
        hantei = []
        if s[i][j] == "
            for dx, dy in move:
                if i+dx<0 or j+dy<0 or i+dx>h-1 or j+dy>w-1:
                    continue
                else:
                    hantei.append(s[i+dx][j+dy])
            if "
                flag = 0
                break

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

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

di = (0, 1, 0, -1) 
dj = (1, 0, -1, 0)

ans = 'Yes'
for i in range(h):
  if ans == 'No':
      break
  for j in range(w):
    if ans == 'No':
      break
    count = 0
    if s[i][j] == '
      for k in range(4):
        if i+di[k] < 0 or h <= i+di[k]:
          count += 1
          continue
        elif j+dj[k] < 0 or w <= j+dj[k]:
          count += 1
          continue
        else:
          if s[i+di[k]][j+dj[k]] == '
            break
          else:
            count += 1
    if count == 4:
      ans = 'No'
      break
          
print(ans)

Solution (Python):
h, w = map(int, input().split())
grid = [[0 for _ in range(w+2)] for _ in range(h+2)]
for j in range(1, h+1):
  cnt = 0
  for a in input():
    cnt+=1
    grid[j][cnt]= 1 if a!='.' else 0
grid[1][1]=3

for j in range(1,h+1):
  for i in range(1,w+1):
    if grid[j][i] == 1 and grid[j-1][i] == 0 and  grid[j+1][i] == 0 and grid[j][i-1] == 0 and  grid[j][i+1] == 0:
      print('No')
      exit()
print('Yes')

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

s = []

s.append('.' * (w + 2))

for i in range(h):
  s.append('.' + input() + '.')
  
s.append('.' * (w + 2))
  
sol = 0
for i in range(1, h + 1):
  for j in range(1, w + 1):
    
    if s[i][j] == '
      if not '
        sol += 1
if sol > 0:
  print('No')
else:
  print('Yes')

Solution (Python):
h, w = list(map(int, input().split()))
s = [list(input()) for i in range(h)]
dir = [[-1, 0], [1, 0], [0, -1], [0, 1]]
for y in range(h):
    for x in range(w):
        can_put = True
        if s[y][x] == "
            for dx, dy in dir:
                cx = x + dx
                cy = y + dy
                if cx >= 0 and cx < w and cy >= 0 and cy < h:
                    if s[cy][cx] == "
                        can_put = True
                        break
            else:
                can_put = False
        if can_put == False:
            break
    else:
        continue
    break
if can_put == True:
    print("Yes")
else:
    print("No")