import numpy as np

h, w = list(map(int, input().split()))

s = [list(eval(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)

import numpy as np

h, w = list(map(int, input().split()))

s = np.array([list(eval(input())) for _ in range(h)])

w1, w2 = np.array(["."]*h), np.array(["."]*(w+2))

s = np.hstack((w1.reshape(len(w1),1), s))

s = np.hstack((s, w1.reshape(len(w1),1)))

s = np.vstack((w2, s))

s = np.vstack((s, w2))

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

for i in range(1, h+1, 1):

    for j in range(1, w+1, 1):

        now = s[i][j]

        c = 0

        if now == ".":

            continue

        for d in range(4):

            x = j + dx[d]

            y = i + dy[d]

            if now == s[y][x]:

                c += 1

        if c == 0:

            print("No")

            exit()

print("Yes")
import numpy as np

h, w = list(map(int, input().split()))
s = [list(eval(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)

import numpy as np

h, w = list(map(int, input().split()))
s = np.array([list(eval(input())) for _ in range(h)])
w1, w2 = np.array(["."] * h), np.array(["."] * (w + 2))
s = np.hstack((w1.reshape(len(w1), 1), s))
s = np.hstack((s, w1.reshape(len(w1), 1)))
s = np.vstack((w2, s))
s = np.vstack((s, w2))
dx, dy = [1, 0, -1, 0], [0, 1, 0, -1]
for i in range(1, h + 1, 1):
    for j in range(1, w + 1, 1):
        now = s[i][j]
        c = 0
        if now == ".":
            continue
        for d in range(4):
            x = j + dx[d]
            y = i + dy[d]
            if now == s[y][x]:
                c += 1
        if c == 0:
            print("No")
            exit()
print("Yes")

-s = [list(eval(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] == ".": +s = np.array([list(eval(input())) for _ in range(h)]) +w1, w2 = np.array(["."] * h), np.array(["."] * (w + 2)) +s = np.hstack((w1.reshape(len(w1), 1), s)) +s = np.hstack((s, w1.reshape(len(w1), 1))) +s = np.vstack((w2, s)) +s = np.vstack((s, w2)) +dx, dy = [1, 0, -1, 0], [0, 1, 0, -1] +for i in range(1, h + 1, 1): +    for j in range(1, w + 1, 1): +        now = s[i][j] +        c = 0 +        if now == ".": -        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) +        for d in range(4): +            x = j + dx[d] +            y = i + dy[d] +            if now == s[y][x]: +                c += 1 +        if c == 0: +            print("No") +            exit() +print("Yes")