#include #define rep(i,a,b) for(int i=a;i=b;i--) #define fore(i,a) for(auto &i:a) #pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } //--------------------------------------------------------------------------------------------------- /*---------------------------------------------------------------------------------------------------             ∧_∧       ∧_∧  (´<_` )  Welcome to My Coding Space!      ( ´_ゝ`) /  ⌒i     /   \    | |     /   / ̄ ̄ ̄ ̄/  |   __(__ニつ/  _/ .| .|____      \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ int N, M; int A[1010][1010]; #define no "NO" #define yes "YES" //--------------------------------------------------------------------------------------------------- void _main() { cin >> N >> M; rep(i, 0, M) rep(j, 0, N) cin >> A[i][j]; rep(i, 1, M) rep(j, 0, N) A[i][j] += A[i - 1][j]; rep(i, 0, M) rep(j, 1, N) A[i][j] += A[i][j - 1]; string ans = no; rep(i, 0, M) { rep(j, 0, N) { int d = A[i][j] - 777; if (d < 0) continue; if (d == 0) ans = yes; int k = lower_bound(A[i], A[i] + j, d) - A[i]; if (k != j) if (A[i][j] - A[i][k] == 777) ans = yes; } } cout << ans << endl; }