def check(l): s = 0 e = 1 for _ in range(0, 2 * len(l)): su = sum(l[s:e]) if su == 777: return True elif su > 777: s += 1 elif su < 777: e += 1 if s == e and e >= len(l): return False return False def solve(N, M, data): train = [0 for _ in range(0, N)] for d in data: di = [int(k) for k in d.split(" ")] train = [t + d for t, d in zip(train, di)] if sum(train) >= 777: if check(train): return "YES" return "NO" if __name__ == '__main__': N, M = map(int, input().split()) d = [] for _ in range(0, M): d.append(input()) print(solve(N, M, d))