import sys
import math

h, w = map(int, input().split())
li = [[0] * h for i in range(w)]
ans = "Yes"
for i in range(h):
    tmp = input()
    for j in range(w):
        li[i][j] = tmp[j]
# 一行目
for j in range(1, w-1):
    if li[0][j - 1] != li[0][j] and li[0][j + 1] != li[0][j] and li[0][j] != li[1][j]:
        ans = "No"
for i in range(1, h-1):
    for j in range(1, w-1):
        if (
            li[i][j - 1] != li[i][j]
            and li[i][j + 1] != li[i][j]
            and li[i][j] != li[i - 1][j]
            and li[i][j] != li[i + 1][j]
        ):
            ans = "No"
for j in range(1, w-1):
    if (
        li[h-1][j - 1] != li[h-1][j]
        and li[h-1][j + 1] != li[h-1][j]
        and li[h-1][j] != li[h - 2][j]
    ):
        ans = "No"
print(ans)

