n, m = gets.chomp.split.map(&:to_i) trains = Array.new(n){0} while tmp = gets tmp = tmp.chomp.split.map(&:to_i) (0..n-1).each do |k| trains[k] += tmp[k] end sum = 0 (0..n-1).each do |i| sum = trains[i] if sum == 777 puts 'YES' exit end (i+1..n-1).each do |j| sum += trains[j] if sum == 777 puts 'YES' exit end end end puts 'NO' exit end