#include #include using namespace std; using namespace atcoder; // デバッグ用 #ifndef ONLINE_JUDGE #define _GLIBCXX_DEBUG #endif #define nall(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define YES cout << "Yes\n" #define NO cout << "No\n" #define YN {cout << "Yes\n";}else{cout << "No\n";} #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) #define PRECISION(x) cout << fixed << setprecision(x) #define endl '\n' #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define each(o, a) for (auto &o : a) using ll = long long; using ld = long double; using ull = unsigned long long; template using vc = vector; template using vv = vc>; using vi = vc; using pii = pair; using pll = pair; using vl = vc; using vvl = vv; using vvvl = vv; const int MOD = 998244353; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll n, m; cin >> n >> m; vl a(n); bool can = false; rep (i, m) { rep (i, n) { ll t; cin >> t; a[i] += t; } ll r = 0, sum = 0; rep (l, n) { while (r < n && sum < 777) { sum += a[r]; r++; } if (sum == 777) can = true; sum -= a[l]; } } if (can) cout << "YES" << endl; else cout << "NO" << endl; return 0; }