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 loop do while s < 777 and j < n s += a[j] j += 1 end while s > 777 and i < j s -= a[i] i += 1 end if s == 777 ok = true break end break if j >= n end if ok puts :YES exit end end puts :NO