#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) { 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(k, N) { ui cur = Sums[k]; if (Train[i][k] == 777 || Sums[k] == 777) { return true; } FOR0(j, k) { cur -= Sums[j]; if (cur == 777) { return true; } } } } return false; } int main(void) { cin >> N >> M; FOR0(i, M) { FOR0(j, N) { cin >> Differences[i][j]; } } cout << (solve() ? "YES" : "NO") << endl; return 0; }