nums = list(map(int, input().split()))
H=nums[0]
W=nums[1]
Strings=[]
for k in range(H):
    Strings.append(input())
for i in range(H):
    list(Strings[i])
    c=0
    for j in range(1, W):
        if Strings[i][j]==Strings[i][j-1]:
            c=1
for l in range(W):
    for m in range(1,H):
        if Strings[i][j]==Strings[i-1][j]:
            c=1
if c==1:
    print("Yes") 
else:
    print("No")