class Dice
  attr_accessor :face

  Edge = [[0,1,2],[0,2,4],[0,4,3],[0,3,1],[1,5,2],[2,5,4],[4,5,3],[3,5,1]]

  #topとfrontの数字を渡すと右の面のindexを返してくれる
  def query(top, front)
    x,y = @face.index(top),@face.index(front)
    Edge.each do |item|
      if i = item.index(y)
        if item[i-1] == x
          right = item[i-2]
          return right
        end
      end
    end
  end

  def rotate(dir)
    case dir
    when "N"
    @face[0],@face[1],@face[5],@face[4] = @face[1],@face[5],@face[4],@face[0]
    when "E"
    @face[0],@face[2],@face[5],@face[3] = @face[3],@face[0],@face[2],@face[5]
    when "S"
    @face[0],@face[1],@face[5],@face[4] = @face[4],@face[0],@face[1],@face[5]
    when "W"
    @face[0],@face[2],@face[5],@face[3] = @face[2],@face[5],@face[3],@face[0]
    end
  end
end

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

if dice1.face[dice1.query(dice2.face[0], dice2.face[1])] == dice2.face[dice2.query(dice2.face[0], dice2.face[1])] && \
  dice1.face[dice1.query(dice2.face[1], dice2.face[5])] == dice2.face[dice2.query(dice2.face[1], dice2.face[5])] && \
  dice1.face[dice1.query(dice2.face[5], dice2.face[4])] == dice2.face[dice2.query(dice2.face[5], dice2.face[4])] && \
  dice1.face[dice1.query(dice2.face[1], dice2.face[0])] == dice2.face[dice2.query(dice2.face[1], dice2.face[0])]
  puts "Yes"
else
  puts "No"
end