class PhraseFinder def initialize(phrase = 'LOVE') @n, _ = gets.split(' ').map(&:to_i) @phrase = phrase @found = false end def find! @n.times do @found = true and break if found? end puts @found ? 'YES' : 'NO' end private def found? gets.include?(@phrase) end end PhraseFinder.new.find!