#include using namespace std; int n, m; int main(void){ // Your code here! cin >> n >> m; int A[m][n]; int B[m][n+1]; for(int i = 0; i < m; i++){ for(int j = 1; j <= n; j++){ cin >> A[i][j]; } } for(int i = 1; i < m; i++){ for(int j = 1; j <= n; j++){ A[i][j] = A[i][j] + A[i-1][j]; } } for(int i = 0; i < m; i++){ B[i][0] = 0; for(int j = 1; j <= n; j++){ B[i][j] = B[i][j-1] + A[i][j]; } } for(int k = 0; k < m; k++){ for(int i = 1; i <= n; i++){ for(int j = 1; j <= i; j++){ if(B[k][i] - B[k][j-1] == 777){ cout << "YES" << endl; return 0; } } } } cout << "NO" << endl; }