h,w = map(int,input().split())
a = []
for i in range(h):
  a.append(input())
for i in range(h):
  for j in range(w):
    if i !=0:
      if a[i][j] != a[i-1][j]:
        print("No")
        quit()
    if j !=0:
      if a[i][j] != a[i][j-1]:
        print("No")
        quit()
    if i !=h:
      if a[i][j] != a[i+1][j]:
        print("No")
        quit()
    if j !=w:
      if a[i][j] != a[i][j+1]:
        print("No")
        quit()
print("Yes")