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-2):
    if s[0][i] == s[0][i-1] or s[0][i] == s[1][i-1] or s[0][i] == s[0][i+1] or s[H-1][i] == s[H-1][i-1] or s[H-1][i] == s[H-2][i] or s[H-1][i] == s[H-1][i+1]:
        pass
    else:
        frg = 1
        
for i in range(1, W-2):
    if s[i][0] == s[i-1][0] or s[i][0] == s[i-1][1] or s[i][0] == s[i+1][0] or s[i][W-1] == s[i-1][W-1] or s[i][W-1] == s[i][W-2] or s[i][W-1] == s[i+1][W-1]:
        pass
    else:
        frg = 1
if 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:
            break
    
if frg == 0:
    print('Yes')
else:
    print('No')

