# ITP1_11_B: Dice 3

class Dice
  Side = Struct.new :neighbors

  module Dir
    UP    = 0
    RIGHT = 1
    DOWN  = 2
    LEFT  = 3
  end

  class << self
    # Create new Dice which has +labels+ as its faces.
    # The +labels+ have to be ordered as [ top, front, right, left, back, bottom ]
    # and each label has to be unique.
    def create(name, *labels)
      faces = layout_faces(*labels)
      dice_class = const_set name, Class.new(self)
      dice_class.const_set :FACES, faces
      dice_class
    end

    #       top
    # left front right (back)
    #      bottom
    def layout_faces(top, front, right, left, back, bottom)
      Hash.new.tap do |faces|
        faces[front]  = Side.new [top, right, bottom, left]
        faces[back]   = Side.new [bottom, right, top, left]
        faces[top]    = Side.new [front, left, back, right]
        faces[right]  = Side.new [front, top, back, bottom]
        faces[bottom] = Side.new [front, right, back, left]
        faces[left]   = Side.new [front, bottom, back, top]
      end
    end

    def same_pattern?(other)
      return false unless other <= Dice
      s_faces = self::FACES
      o_faces = other::FACES

      a_side = s_faces.keys[0]
      return false unless o_faces.has_key? a_side

      s_neighbors  = s_faces[a_side].neighbors
      o_neighbors  = o_faces[a_side].neighbors
      pos_in_other = o_neighbors.index s_neighbors[0]
      return false if pos_in_other.nil?

      step = pos_in_other % s_neighbors.size
      s_neighbors == o_neighbors.rotate(step)
    end
  end


    def initialize( top, front = face_of(top).neighbors[ Dir::DOWN ] )
      put_upward top, front
    end

    def top_side
      @top_side
    end

    def number_on(dir_id)
      @neighbors[dir_id]
    end

    def roll_to(direction)
      dir_id   = dir_to_id direction
      next_top = opposite_side dir_id
      put_upward next_top, @top_side, dir_id
    end

    def put_upward(top, a_side, dir_id = Dir::DOWN)
      @neighbors = rotate_neighbors_of top, a_side, dir_id
      @top_side  = top
      self
    end

    def opposite_side(dir_id)
      di_rid = (dir_id + 2) % @neighbors.size
      @neighbors[di_rid]
    end

  private

    def face_of(number)
      self.class::FACES[number]
    end

    def rotate_neighbors_of(top, a_side, dir_id)
      neighbors = face_of(top).neighbors
      org_dir   = neighbors.index(a_side)
      step = (org_dir - dir_id) % neighbors.size
      neighbors.map.with_index do |n, idx|
        neighbors[ (idx + step) % neighbors.size ]
      end
    end

    def dir_to_id(dir_id)
      case dir_id
      when 'N' then Dir::UP
      when 'E' then Dir::RIGHT
      when 'S' then Dir::DOWN
      when 'W' then Dir::LEFT
      end
    end
end


labels_a = gets.chomp.split.map &:to_i
labels_b = gets.chomp.split.map &:to_i

DiceA = Dice.create :DiceA, *labels_a
DiceB = Dice.create :DiceB, *labels_b
puts ( DiceA.same_pattern? DiceB ) ? 'Yes' : 'No'