#include #include #include #include #include #include #include #include #include #include #include #include #include #define p(s) cout<<(s)<=n;i--) #define CK(n,a,b) ((a)<=(n)&&(n)<(b)) #define F first #define S second typedef long long int ll; using namespace std; const ll mod=1e9+7; int N, M; int a[1010][1010]; int main(){ cin>>N>>M; REP(i,0,M){ REP(j,0,N){ cin>>a[i][j]; } } REP(i,0,M-1){ REP(j,0,N) a[i+1][j] += a[i][j]; } bool ok=false; REP(i,0,M){ int r=0; int sum=a[i][0]; REP(l,0,N){ if(sum==777){ ok=true; break; }else if(sum>777||r==N-1){ sum-=a[i][l]; }else{ r++; l--; sum+=a[i][r]; } } if(ok) break; } p(ok?"YES":"NO"); return 0; }