N, M = map(int, input().split()) t = [0] * N for _ in range(M): a = list(map(int, input().split())) for i in range(N): t[i] += a[i] right, s = 0, 0 for left in range(N): while right < N and s + t[right] <= 777: s += t[right] right += 1 if s == 777: print('YES') break if left == right: right += 1 else: s -= t[left] else: continue break else: print('NO')