N, M = map(int, input().split()) s = [0] * (N + 1) for j in range(M): a = list(map(int, input().split())) for i in range(1, N): a[i] += a[i - 1] for i in range(1, N + 1): s[i] += a[i - 1] #print(s) r = 1 for l in range(N): while r <= N: if s[r] - s[l] == 777: print("YES") exit() elif s[r] - s[l] < 777: r += 1 else: break print("NO")