# ITP1_11_B: Dice3

class Dice
  Side = Struct.new :sides, :back

  TOP    = 0
  FRONT  = 1
  RIGHT  = 2
  LEFT   = 3
  BACK   = 4
  BOTTOM = 5

  def initialize(labels)
    @labels = labels
    @sides  = layout_map
  end

  def pip_of(side)
    @labels[side]
  end

  def sides_of(side)
    @sides[side].sides
  end

  def back_of(side)
    @sides[side].back
  end
 
  def rotate(p1, p2, p3, p4)
    l = @labels
    l[p1], l[p2], l[p3], l[p4] = l[p4], l[p1], l[p2], l[p3]
  end
 
  def roll_to(direction)
    rotate *case direction
    when 'N'
      [TOP, FRONT, BOTTOM, BACK]
    when 'E'
      [TOP, LEFT, BOTTOM, RIGHT]
    when 'S'
      [TOP, BACK, BOTTOM, FRONT]
    when 'W'
      [TOP, RIGHT, BOTTOM, LEFT]
    end
  end

  def each_side
    @labels.each_with_index
  end

  def same_as?(other)
    mytop   = self.pip_of TOP
    mysides = self.sides_of TOP
    myback  = self.back_of TOP

    other.each_side.any? do |label, id|
      next unless mytop == label && myback == other.back_of(id)
      other_sides = other.sides_of(id)
      mysides.size.times.any? do
        mysides == other_sides.rotate!(1)
      end
    end
  end

  private

    def layout_map()
      Hash.new.tap do |sides|
        sides[TOP]    = make_sides [FRONT, RIGHT, BACK, LEFT], BOTTOM
        sides[FRONT]  = make_sides [BOTTOM, RIGHT, TOP, LEFT], BACK
        sides[RIGHT]  = make_sides [BOTTOM, BACK, TOP, FRONT], LEFT
        sides[LEFT]   = make_sides [BOTTOM, FRONT, TOP, BACK], RIGHT
        sides[BACK]   = make_sides [TOP, RIGHT, BOTTOM, LEFT], FRONT
        sides[BOTTOM] = make_sides [BACK, RIGHT, FRONT, LEFT], TOP
      end
    end

    def make_sides(sides, back)
      Side.new sides.map{ |id| @labels[id] }, @labels[back]
    end
end

labels1 = gets.chomp.split.map &:to_i
labels2 = gets.chomp.split.map &:to_i

dice1 = Dice.new labels1
dice2 = Dice.new labels2
puts dice1.same_as?(dice2) ? 'Yes' : 'No'