from collections import deque n,m=map(int,input().split()) a=[list(map(int,input().split())) 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): q=deque() now=0 for j in range(n): now+=a[i][j] q.append(a[i][j]) while q and now>777: out=q.popleft() now-=out if now==777: print('YES') exit() print('NO')