#include using namespace std; static const int INF = 1e9 + 7; template using Vec = vector; template using P = pair; template using Tup = tuple; using llong = long long; using ullong = unsigned long long; using uint = unsigned int; void hawawa() { int n, m; cin >> n >> m; vector a(n); for (int i = 0; i < m; i++) { int s = 0, cnt = 0; for (int g = 0; g < n; g++) { int num; cin >> num; a[g] += num; while (777 < cnt + a[g]) { cnt -= a[s]; s++; } cnt += a[g]; if (cnt == 777) { cout << "YES\n"; return; } } } cout << "NO\n"; } int main() { ios::sync_with_stdio(false); cin.tie(0); hawawa(); }