a = gets.split(" ").map(&:to_i) b = gets.split(" ").map(&:to_i) 3.times do |i| 3.times do |n| c, d = a.dup, b.dup c[i], d[n] = d[n], c[i] if (c.uniq.size == 3) && (d.uniq.size == 3) && (c.max == c[1] || c.min == c[1]) && (d.max == d[1] || d.min == d[1]) puts "Yes" exit end end end puts "No"