#include #define rep(i, n) for (int i = 0; i < (n); i++) #define repr(i, n) for (int i = (n) - 1; i >= 0; i--) #define repe(i, l, r) for (int i = (l); i < (r); i++) #define reper(i, l, r) for (int i = (r) - 1; i >= (l); i--) #define repi(i, l, r) for (int i = (l); i <= (r); i++) #define repir(i, l, r) for (int i = (r); i >= (l); i--) #define range(a) a.begin(), a.end() void init_io() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(15); } using namespace std; using ll = long long; int main() { init_io(); int H, W; cin >> H >> W; vector G(H); rep(i, H) cin >> G[i]; vector col(W), row(H); rep(i, H) rep(j, W) { col[j] += G[i][j] - '0'; row[i] += G[i][j] - '0'; } bool any = false; rep(i, H) rep(j, W) { any |= row[i] == 0 && col[j] == 0; any |= row[i] == W && col[j] == H; } cout << (!any ? "YES" : "NO") << endl; }