from collections import deque

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

s = deque()

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

frg = 0

for i in range(1, H-1):
    for l in range(1, W-1):
        if s[i][l] == s[i-1][l] or s[i][l] == s[i][l-1] or s[i][l] == s[i+1][l] or s[i][l] == s[i][l+1]:
            pass
        else:
            frg = 1
            break
    if frg == 1:
        print('No')
        break
if frg == 0:
    print('Yes')
