# coding: utf-8 # Your code here! import sys sys.setrecursionlimit(10**6) readline = sys.stdin.readline #n = int(input()) h,w = [int(i) for i in readline().split()] b = [input() for _ in range(h)] def yoko(x): bx = b[x] c = bx[0] ok = 0 for i in range(w): if bx[i] != c: ok = 1 return ok def tate(x): c = b[0][x] ok = 0 for i in range(h): if b[i][x] != c: ok = 1 return ok ok = 0 if all(yoko(i) for i in range(h)): ok = 1 if all(tate(i) for i in range(w)): ok = 1 if ok: print("Yes") else: print("No")