n, m = gets.chomp.split.map(&:to_i) a = [0] * n m.times do xs = gets.chomp.split.map(&:to_i) n.times do |i| a[i] += xs[i] end s = a[0] i = 0 j = 1 ok = false while i < j while s < 777 and j < n s += a[j] j += 1 end if s == 777 ok = true break end if s > 777 s -= a[i] i += 1 end break if j >= n end if ok puts :YES exit end end puts :NO