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 self end def to_s @found ? 'YES' : 'NO' end private def found? gets.include?(@phrase) end end puts PhraseFinder.new.find!