#include #include #include using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N, M, i, j, k, sum; cin >> N >> M; vector a(N), count(N, 0); for (i = 0; i != M; ++i) { for (j = 0; j != N; ++j) cin >> a[j], count[j] += a[j]; for (j = k = sum = 0; k != N || sum >= 777; ) { if (sum < 777) sum += count[k++]; else if (sum != 777) sum -= count[j++]; else { cout << "YES\n"; return 0; } } } cout << "NO\n"; return 0; }