w=gets.split s=w.index(??) puts %w(1 4).map {|x| w[0...s] + [x] + w[(s+1)..-1] }.to_a.map{|x| x.map(&:to_i) }.filter {|x| x.minmax.include?(x[1])}.map{|x| x[s] } * ""