def densya(): N, M = map(int, input().split()) n = [0 for _ in range(N)] ans = False for i in range(M): add = list(map(int, input().split())) n = [n[k] + add[k] for k in range(N)] for j in range(N): sum = 0 count = 0 while sum < 777: if j + count >= N: break sum += n[j + count] count += 1 if sum == 777: ans = True return ans if densya(): print("YES") else: print("NO")