class Dice
  def initialize(n)
    @n = n
  end
  #     ^N
  #     [0]:top
  # [3] [1] [2] [4]  2:right 3:left 4:back
  #     [5]:bottom
  #     vS
  attr_reader :n

  def roll(d)
    case d
    when ?N
      @n = [@n[1], @n[5], @n[2], @n[3], @n[0], @n[4]]
    when ?S
      @n = [@n[4], @n[0], @n[2], @n[3], @n[5], @n[1]]
    when ?E
      @n = [@n[3], @n[1], @n[0], @n[5], @n[4], @n[2]]
    when ?W
      @n = [@n[2], @n[1], @n[5], @n[0], @n[4], @n[3]]
    else
      raise
    end
    self
  end
  def rotate_right
    @n = [@n[0], @n[2], @n[4], @n[1], @n[3], @n[5]]
    self
  end
  def rotate_left
    @n = [@n[0], @n[3], @n[1], @n[4], @n[2], @n[5]]
    self
  end
  def set_up_n_front(u, f)
    raise if u == f || (u+f) == 7
    case @n.index(u)
    when 0
      ;
    when 1
      self.roll(?N)
    when 2
      self.roll(?W)
    when 3
      self.roll(?E)
    when 4
      self.roll(?S)
    when 5
      self.roll(?N)
      self.roll(?N)
    end
    case @n.index(f)
    when 1
      ;
    when 2
      self.rotate_right
    when 3
      self.rotate_left
    when 4
      self.rotate_left.rotate_left
    when 0, 5
      raise
    end
    self
  end
end

d1=Dice.new(gets.split.map(&:to_i))
d2=Dice.new(gets.split.map(&:to_i))
r1=d1.set_up_n_front(1, 2).n[2]
r2=d2.set_up_n_front(1, 2).n[2]
puts (r1==r2 ? "Yes" : "No")


