class Dice

  def initialize( given_ary )
    @ary = given_ary
  end

  def topface( val )
    4.times do
      self.roll( "E" )
      if self.top == val
        return
      end
    end
    3.times do
      self.roll( "N" )
      if self.top == val
        return
      end
    end
  end

  def frontface( val )
    4.times do
      tmp = @ary[1]
      @ary[1] = @ary[2]
      @ary[2] = @ary[4]
      @ary[4] = @ary[3]
      @ary[3] = tmp
      if @ary[1] == val
        return
      end
    end
  end

  def roll( direction )
    case direction.downcase
    when "e"
      tmp = @ary[0]
      @ary[0] = @ary[3]
      @ary[3] = @ary[5]
      @ary[5] = @ary[2]
      @ary[2] = tmp
    when "w"
      tmp = @ary[0]
      @ary[0] = @ary[2]
      @ary[2] = @ary[5]
      @ary[5] = @ary[3]
      @ary[3] = tmp
    when "s"
      tmp = @ary[0]
      @ary[0] = @ary[4]
      @ary[4] = @ary[5]
      @ary[5] = @ary[1]
      @ary[1] = tmp
    when "n"
      tmp = @ary[0]
      @ary[0] = @ary[1]
      @ary[1] = @ary[5]
      @ary[5] = @ary[4]
      @ary[4] = tmp
    end
  end

  def top
    @ary[ 0 ]
  end

  def front
    @ary[ 5 ]
  end

  def right
    @ary[ 2 ]
  end

  def vals
    @ary
  end

  def identical( givendice )
    p @ary
    @ary.zip( givendice.vals ).map{ | x, y | ( x - y ).abs }.inject(:+) == 0
  end

end


dice1 = Dice.new( gets.split.map(&:to_i) )
dice2 = Dice.new( gets.split.map(&:to_i) )
dice2.topface( dice1.top )
dice2.frontface( dice1.front )
puts ( dice1.identical( dice2 ) )? "Yes": "No"