require "stringio" using Module.new { refine TrueClass do def to_s "YES" end end refine FalseClass do def to_s "NO" end end } input = StringIO.new(<<~EOS) 4 4 LLLL OOOO VVVV EEEE EOS input = $stdin puts input.gets.split.map(&:to_i).first.times.lazy.map { input.gets }.any?(/LOVE/).to_s