#include using namespace std::literals::string_literals; using i64 = std::int_fast64_t; using std::cout; using std::endl; using std::cin; template std::vector make_v(size_t a){return std::vector(a);} template auto make_v(size_t a,Ts... ts){ return std::vector(ts...))>(a,make_v(ts...)); } int main() { // input int h, w; scanf("%d%d", &h, &w); std::vector s(h); for(int i = 0; i < h; i++) cin >> s[i]; // solve bool X = true, Y = true; for(int loop = 0; loop < 2; loop++) { for(int i = 0; i < h; i++) { int x = 0, y = 0; for(int j = 0; j < w; j++) { if(loop) std::swap(i, j); x += (s[i][j] == '0'); y += (s[i][j] == '1'); if(loop) std::swap(i, j); } X &= (x and y); } std::swap(h, w); std::swap(X, Y); } if(X or Y) printf("YES\n"); else printf("NO\n"); return 0; }