class Dice
  attr_accessor :status
  def initialize(status)
    @status = status
  end

  def compareSpec(dice)
    @d2 = dice.status
    d1 = matchDirect(@d2)
    return (d1 == @d2) ? true : false
  end

  def matchDirect(d2)
    dt = Array.new(6)
    2.times do |i|
      idx = detectIndex(i)
      dt[i] = @status[idx]
      dt[5-i] = @status[5-idx]
    end
    top = @status.index(dt[0]) + 1
    front = @status.index(dt[1]) + 1
    idx = detectSideIndex(top,front)
    dt[2] = @status[idx]
    dt[3] = @status[5-idx]
    return dt
  end

  def detectIndex(i)
    idx = 0
    @status.each_with_index do |dir,j|
      if ((dir == @d2[i]) && (@status[5-j] == @d2[5-i]))
        idx = j
        break
      end
    end
    return idx
  end

  def detectSideIndex(top,front)
    idx = 0
    case top
    when 1,6
      s = [2,3,5,4]
      while (s.include?(front))&&(s[0] != front) do
        s.unshift(s.pop)
      end
      idx = (top == 1) ? s[1] - 1 : s[-1] - 1
    when 2,5
      s = [1,4,6,3]
      while (s.include?(front))&&(s[0] != front) do
        s.unshift(s.pop)
      end
      idx = (top == 2) ? s[1] - 1 : s[-1] - 1
    when 3,4
      s = [1,2,6,5]
      while (s.include?(front))&&(s[0] != front) do
        s.unshift(s.pop)
      end
      idx = (top == 3) ? s[1] - 1 : s[-1] - 1
    end
    return idx
  end
end

d1 = Dice.new(gets.split.map(&:to_i))
d2 = Dice.new(gets.split.map(&:to_i))
result = d1.compareSpec(d2)
puts (result == true) ? "Yes" : "No"