#!/usr/bin/env python3 from collections import Counter, deque from itertools import accumulate dpos4 = ((1, 0), (0, 1), (-1, 0), (0, -1)) def main(): N, M = map(int, input().split()) count = [0] * N for _ in range(M): A = list(map(int, input().split())) for i in range(N): count[i] += A[i] acc = [0] + list(accumulate(count)) right = 0 for left in range(N + 1): right = max(left, right) while right < N + 1 and acc[right] - acc[left] < 777: right += 1 if right == N + 1: break if acc[right] - acc[left] == 777: print("YES") return print("NO") if __name__ == '__main__': main()