class Dice
  attr_accessor :face

  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]
    when "cw" #ClockWise rotation
      self.rotate("E").rotate("N").rotate("W")
      #@face[1],@face[2],@face[4],@face[3] = @face[2],@face[4],@face[3],@face[1]
    when "acw" #Anti ClockWise rotation
      self.rotate("W").rotate("N").rotate("E")
      #@face[1],@face[2],@face[4],@face[3] = @face[3],@face[1],@face[2],@face[4]
    end
    return self
  end

  def aline_dir(top, front)
    alined_dice = []
    self.face.each_with_index do |item, index|
      dice_clone = Marshal.load(Marshal.dump(self))
      if item == top
        case index
        when 1
          dice_clone.rotate("N")
        when 2
          dice_clone.rotate("W")
        when 3
          dice_clone.rotate("E")
        when 4
          dice_clone.rotate("S")
        when 5
          dice_clone.rotate("N").rotate("N")
        end
        (1..4).each do |i|
          dice_clone2 = Marshal.load(Marshal.dump(dice_clone))
          if dice_clone.face[i] == front
            case i
            when 2
              dice_clone2.rotate("cw")
            when 3
              dice_clone2.rotate("acw")
            when 4
              dice_clone2.rotate("cw").rotate("cw")
            end
            alined_dice.push(dice_clone2.face)
          end
        end
      end
    end
    return alined_dice
  end
  
  def same?(dice_alined)
    bool = false
    dice_alined.each do |item|
      bool = true if self.face.eql?(item)
    end
    return bool
  end
end

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

dice2_alined = dice2.aline_dir(dice1.face[0], dice1.face[1])
puts dice1.same?(dice2_alined) ? "Yes" : "No"