dice1 = gets.split.map(&:to_i)
dice2 = gets.split.map(&:to_i)
throw = {E: [3, 2, 6, 1, 5, 4], N: [5, 1, 3, 4, 6, 2],
         S: [2, 6, 3, 4, 1, 5], W: [4, 2, 1, 6, 5, 3]}
@th = {}
throw.each_key {|k| @th[k] = throw[k].map(&:pred)}

def each(dice)
  yield(dice)
  %W(N NN NNN NW NWW NWWW NNW NNWW NNWWW W WW WWW SW SWW SWWW).each do |commands|
    dice1 = dice
    commands.each_char do |c|
      next_dice = Array.new(6, 0)
      dice1.each_with_index do |d, i|
        next_dice[@th[c.to_sym][i]] = d
      end
      yield(next_dice)
      dice1 = next_dice
    end
  end
end

is_same_dice = ->(dice1, dice2) {
  each(dice1) {|d| return true if d == dice2}
  false
}

puts is_same_dice.(dice1, dice2) ? "Yes" : "No"

