class Dice
    @numbers = []

    def initialize numbers
        @numbers = numbers
    end

    def roll direction
        old = @numbers.dup
        case direction
        when "N"
            @numbers[0] = old[1]
            @numbers[1] = old[5] 
            @numbers[5] = old[4]
            @numbers[4] = old[0]
            @numbers[2] = old[2]
            @numbers[3] = old[3]
        when "E"
            @numbers[3] = old[5]
            @numbers[0] = old[3] 
            @numbers[2] = old[0]
            @numbers[5] = old[2]
            @numbers[1] = old[1]
            @numbers[4] = old[4]
        when "S"
            @numbers[0] = old[4]
            @numbers[1] = old[0] 
            @numbers[5] = old[1]
            @numbers[4] = old[5]
            @numbers[2] = old[2]
            @numbers[3] = old[3]
        when "W"
            @numbers[3] = old[0]
            @numbers[0] = old[2] 
            @numbers[2] = old[5]
            @numbers[5] = old[3]
            @numbers[1] = old[1]
            @numbers[4] = old[4]
        end
    end

    def top
        @numbers[0]
    end
    
    def right t, f
        case @numbers.index(f)
        when 0 then roll "S"
        when 2 then roll "W"; roll "S"
        when 3 then roll "E"; roll "S"
        when 4 then roll "S"; roll "S"
        when 5 then roll "N"
        end

        case @numbers.index(t)
        when 0 then #pass
        when 2 then roll "W"
        when 3 then roll "E"
        when 5 then roll "E"; roll "E"
        else return nil
        end

        @numbers[2]
    end
end

numbers1 = gets.chomp.split.map(&:to_i)
dice1 = Dice.new(numbers1)
numbers2 = gets.chomp.split.map(&:to_i)
dice2 = Dice.new(numbers2)

if (numbers1.sort == numbers2.sort) && (dice1.right(numbers1[0], numbers1[1]) == dice2.right(numbers1[0], numbers1[1]))
    puts "Yes"
else
    puts "No"
end