#include <bits/stdc++.h>   using namespace std;   const int N = 2e3 + 789;   const int M = 2e5 + 5;   const int NN = 1e5 + 55;   const long long mod = 1e9 + 7;   const long long inf = 0x3f3f3f3f;   const long long INF = 1LL << 62;   bitset<2000> P[N], S[N], T;   char ms[N][N];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, m;     cin >> n >> m;     P[0].reset();     for (int i = 0; i < n; i++) {       cin >> ms[i];       if (i) P[i] = P[i - 1];       for (int j = 0; j < m; j++) {         if (ms[i][j] ==  1 ) P[i][j] = 1;       }     }     for (int i = n - 1; i >= 0; i--) {       if (i != n - 1) S[i] = S[i + 1];       for (int j = 0; j < m; j++) {         if (ms[i][j] ==  1 ) S[i][j] = 1;       }     }     bool f = 0;     for (int i = 0; i < n; i++) {       T.reset();       if (i - 1 >= 0) T |= P[i - 1];       if (i + 1 < n) T |= S[i + 1];       if (T.count() == m) f = 1;     }     if (f)       cout <<  YES  << endl;     else       cout <<  NO  << endl;   }   