#include using namespace std; using ll = long long; using PII = pair; #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(x) x.begin(), x.end() template void chmin(T &a, const T &b) { a = min(a, b); } template void chmax(T &a, const T &b) { a = max(a, b); } struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio; #ifdef DEBUG_ #include "../program_contest_library/memo/dump.hpp" #else #define dump(...) #endif const ll INF = 1LL<<60; int main(void) { ll h, w; cin >> h >> w; vector s(h); REP(i, h) cin >> s[i]; bool f_all0 = false, f_all1 = false; REP(i, h) { ll cnt0 = 0, cnt1 = 0; REP(j, w) { if(s[i][j] == '0') cnt0++; else cnt1++; } if(cnt0 == w) f_all0 = true; if(cnt1 == w) f_all1 = true; } bool g_all0 = false, g_all1 = false; REP(i, w) { ll cnt0 = 0, cnt1 = 0; REP(j, h) { if(s[j][i] == '0') cnt0++; else cnt1++; } if(cnt0 == h) g_all0 = true; if(cnt1 == h) g_all1 = true; } if((f_all0 && g_all0) || (f_all1 && g_all1)) cout << "NO" << endl; else cout << "YES" << endl; return 0; }