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)}

rotate = ->(dir, dice) {
  next_dice = Array.new(6, 0)
  dice.each_with_index do |d, i|
    next_dice[th[dir][i]] = d
  end
  next_dice
}

stack = []
dice = dice2
next_dice = loop do
  [:E, :N, :S, :W].each {|d| stack << [dice, d]}
  dice, dir = stack.shift
  next_dice = rotate.(dir, dice)
  if next_dice[1] == dice1[1]
    break next_dice
  else
    dice = next_dice
  end
end

result = "No"
4.times do
  if next_dice == dice1
    result = "Yes"
    break
  end
  next_dice = rotate.(:E, next_dice)
end
puts result

