/* -*- coding: utf-8 -*-
 *
 * 607.cc: No.607 開通777年記念 - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;
const int MAX_M = 1000;
const int TARGET = 777;

/* typedef */

/* global variables */

int as[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);

  for (int i = 0; i < m; i++) {
    int sum = 0;
    for (int j = 0, k = 0; j < n;) {
      int aij;
      scanf("%d", &aij);

      as[j] += aij;
      sum += as[j++];

      while (k < j && sum > TARGET) sum -= as[k++];
      if (sum == TARGET) {
	puts("YES");
	return 0;
      }
    }
  }

  puts("NO");
  return 0;
}