dice0 = STDIN.gets.chomp().split(" ")
dice1 = STDIN.gets.chomp().split(" ")

def move(direction, dice)
  case direction
  when "S" then
    temp = dice[0]
    dice[0] = dice[4]
    dice[4] = dice[5]
    dice[5] = dice[1]
    dice[1] = temp
  when "N" then
    temp = dice[0]
    dice[0] = dice[1]
    dice[1] = dice[5]
    dice[5] = dice[4]
    dice[4] = temp
  when "E" then
    temp = dice[0]
    dice[0] = dice[3]
    dice[3] = dice[5]
    dice[5] = dice[2]
    dice[2] = temp
  when "W" then
    temp = dice[0]
    dice[0] = dice[2]
    dice[2] = dice[5]
    dice[5] = dice[3]
    dice[3] = temp
  end
  return dice
end

def getDrection(ran)
  case ran
  when 0
    return "S"
  when 1
    return "N"
  when 2
    return "E"
  when 3
    return "W"
  end
end

while true
  direction = getDrection(rand(4))
  dice0 = move(direction, dice0)
  # p "dice0 = #{dice0}"
  # p "dice1 = #{dice1}"
  # p "dice0.length = #{dice0.length}"
  count = 0
  for i in 0..dice0.length - 1 do
    # p "dice0[i] = #{dice0[i]}"
    # p "dice1[i] = #{dice1[i]}"
    if dice0[i] == dice1[i] then count +=1 end
    # p "count = #{count}"
  end
  if count == 4 then 
    puts "No"
    break
  elsif count == 6 then
    puts "Yes"
    break
  end
end