N, M = map(int, input().split(' ')) xss = [] for i in range(M): xs = list(map(int, input().split(' ')) ) xss.append( xs ) state = xss[0] for s in range(0, N): for e in range(s, N+1): sum_ = sum( state[s:e] ) if sum_ == 777: print("YES") exit() for xs in xss[1:]: state = [s+x for s, x in zip(state, xs) ] shrink = list(filter(lambda x:x!=0 , state)) + [0] i, j, total = 0, 1, shrink[0] while j <= N: if total == 777: print("YES") exit() if total < 777: total += shrink[j] j += 1 else: total -= shrink[i] i += 1 print('NO')