#include #include #include #include #include #include #include #define FOR0(var, max) for (ui (var) = 0; (var) < (max); ++(var)) #define FOR_INV(var, min, max) for (ui (var) = (max) - 1; (var) + 1 > (min); --(var)) #define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++) #define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++) using namespace std; using uc = unsigned char; using ui = unsigned int; using ul = unsigned long long int; using si = signed int; const static ui NMAX = 1000; const static ui MMAX = 1000; static ui N, M; static ui Train[MMAX][NMAX]; static si Differences[MMAX][NMAX]; static si Sums[NMAX]; void print(void) { FOR0(i, M) { FOR0(j, N) { cout << Train[i][j] << " "; } cout << endl; } } bool solve(void) { multiset result; FOR0(j, N) { Train[0][j] = Differences[0][j]; } FOR0(_i, M - 1) { ui i = _i + 1; FOR0(j, N) { Train[i][j] = Differences[i][j] + Train[i - 1][j]; } } FOR0(i, M) { Sums[0] = Train[i][0]; FOR0(_j, N - 1) { ui j = _j + 1; Sums[j] = Sums[j - 1] + Train[i][j]; } FOR0(j, N) { FOR0(_k, N - j) { ui k = _k + j; if (j == k) { result.insert(Train[i][j]); } else { if (j == 0) { result.insert(Sums[k]); } else { result.insert(Sums[k] - Sums[j - 1]); } } } } } return *result.lower_bound(777) == 777; } int main(void) { cin >> N >> M; FOR0(i, M) { FOR0(j, N) { cin >> Differences[i][j]; } } cout << (solve() ? "YES" : "NO") << endl; return 0; }