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