def densya(): N, M = map(int, input().split()) a = [0 for _ in range(N)] isEnd = False for i in range(M): b = list(map(int, input().split())) a = [a[j] + b[j] for j in range(N)] sum = 0 left = 0 for right in range(N): sum += a[right] while sum > 777: sum = sum - a[left] left += 1 if sum == 777: isEnd = True return isEnd if densya(): print("YES") else: print("NO")