
=begin
        0
    3   1   2   4
        5
=end

a = gets.split(" ").map(&:to_i)
b = gets.split(" ").map(&:to_i)

"EEEESEEEESEEEESEEEESREEERREEE".each_char do |i|
    if i.eql?("N") then
        a[0], a[1], a[5], a[4] = a[1], a[5], a[4], a[0]
    elsif i.eql?("S") then
        a[0], a[1], a[5], a[4] = a[4], a[0], a[1], a[5]
    elsif i.eql?("E") then
        a[0], a[2], a[5], a[3] = a[3], a[0], a[2], a[5]
    elsif i.eql?("W") then
        a[0], a[2], a[5], a[3] = a[2], a[5], a[3], a[0]
    elsif i.eql?("R") then
        a[3], a[1], a[2], a[4] = a[4], a[3], a[1], a[2]
    elsif i.eql?("L") then
        a[3], a[1], a[2], a[4] = a[1], a[2], a[4], a[3]
    end

    if a == b then
        print "Yes\n"
        exit
    end
end

print "No\n"


