#!/usr/bin/env python import numpy as np nm = [int(x) for x in input().split()] indats = [] for i in range(nm[1]): indats.append([int(x) for x in input().split()]) npax = np.array([0 for x in range(nm[0])]) for indat in indats: indat = np.array(indat) npax += indat for i in range(nm[0]): sumpax = 0 for j in range(nm[0]-i): sumpax += npax[i+j] if sumpax == 777: print('YES') exit() elif sumpax > 777: break else: continue print('NO')