#include #include #include #include #include #include #include using namespace std; typedef long long ll; vector A[100000]; bool all_0_row, all_1_row, all_0_col, all_1_col; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; int H, W; cin >> H >> W; for(int i = 0; i < H; i++){ for(int j = 0; j < W; j++){ char c; cin >> c; int a = c-'0'; A[i].push_back(a); } } for(int i = 0; i < H; i++){ int cnt = 0; for(int j = 0; j < W; j++){ cnt += A[i][j]; } if(cnt == W) all_1_row = true; if(cnt == 0) all_0_row = true; } for(int j = 0; j < W; j++){ int cnt = 0; for(int i = 0; i < H; i++){ cnt += A[i][j]; } if(cnt == H) all_1_col = true; if(cnt == 0) all_0_col = true; } if(all_0_col && all_0_row) cout << "NO" << endl; else if(all_1_col && all_1_row) cout << "NO" << endl; else cout << "YES" << endl; }