#include #include #include using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 1000000000000000000LL int main(){ int h,w; cin>>h>>w; vector s(h); rep(i,h)cin>>s[i]; bool f = true; rep(i,h){ set S; rep(j,w)S.insert(s[i][j]); if(S.size()==1)f = false; } if(f)cout<<"YES"< S; rep(j,h)S.insert(s[j][i]); if(S.size()==1)f = false; } } if(f)cout<<"YES"<