//↓template↓ #include "bits/stdc++.h" using namespace std; #define Would #define you #define all(n) n.begin(),n.end() #define rall(n) n.rbegin(),n.rend() typedef long long ll; const ll INF = 1e18; const ll MOD = 1e9 + 7; const double EPS = 1e-10; const double pi = acos(-1);//3.1415926535897932384626433832795028... const ll SIZE = 1 << 17; int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30]; ll fac[200005], finv[200005], inv[200005]; vectordij; struct edge { ll to, cost; }; vector >G; ll mod_pow(ll a, ll b) { ll res = 1, mul = a; for (int i = 0; i < 31; ++i) { if (b >> i & 1) { res *= mul; res %= MOD; } mul = (mul * mul) % MOD; } return res; } void addedge(int from, int to, int cost) { G[from].push_back({ to,cost }); G[to].push_back({ from,cost }); } template vector make_v(size_t a) { return vector(a); } template auto make_v(size_t a, Ts... ts) { return vector(ts...))>(a, make_v(ts...)); } template typename enable_if::value == 0>::type fill_v(T & t, const V & v) { t = v; } template typename enable_if::value != 0>::type fill_v(T & t, const V & v) { for (auto& e : t) fill_v(e, v); } template void outp(vectorv) { for (int i = 0; i < v.size(); ++i) { cout << v[i]; if (i != v.size() - 1) { cout << " "; } } } double add(double a, double b) { if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; } return a + b; } //↑template↑ int a, b, k[1005][1005]; int main() { cin >> a >> b; for (int i = 0; i < b; ++i) { for (int j = 0; j < a; ++j) { cin >> k[i][j]; if (i != 0) { k[i][j] += k[i - 1][j]; } } } for (int i = 0; i < b; ++i) { int l = 0, r = 0, mon = 0; for (; l < a; ++l) { while (mon < 777) { if (r == a) { break; } mon += k[i][r]; ++r; } if (mon < b) { break; } if (mon == 777) { cout << "YES" << endl; return 0; } mon -= k[i][l]; } } cout << "NO" << endl; }