import sys sys.setrecursionlimit(10**6) #input = sys.stdin.readline fn=lambda:int(input()) f=lambda:input().split() ff=lambda:map(int,input().split()) fff=lambda:list(map(int,input().split())) from collections import Counter,deque,defaultdict from itertools import combinations,permutations from decimal import Decimal import re,math,bisect,heapq ma=-float('inf') mi=float('inf') mod =10**9+7 dis=((1,0),(-1,0),(0,1),(0,-1)) #import numpy as np #pypyでは使えない ###################宣言################### n,m=ff() A=[fff()for _ in range(m)] for i in range(1,m): for j in range(n): A[i][j]+=A[i-1][j] for i in range(m): dq=deque() t=0 for j in range(n): dq.append(A[i][j]) t+=A[i][j] while dq and t>777: rm=dq.popleft() t-=rm if t==777: print('YES') exit() print('NO')