if (_dice_a = gets.split.map(&:to_i)) == (_dice_b = gets.split.map(&:to_i))
  puts "Yes"
  exit
end

def vertical_roll(new_dice, upper)
  count = 0
  while new_dice[0] != upper && count < 4
    new_dice[0], new_dice[1], new_dice[4], new_dice[5] = new_dice[1], new_dice[5], new_dice[0], new_dice[4]
  end
  new_dice
end

def horizontal_roll(new_dice, front)
  count = 0
  while new_dice[1] != front && count < 4
    new_dice[1], new_dice[2], new_dice[4], new_dice[3] = new_dice[2], new_dice[4], new_dice[3], new_dice[1]
    count += 1
  end
  new_dice
end

_dice_b_idx = _dice_b.index(_dice_a[0])

case _dice_b_idx
when 0,1,4,5
  vertical_roll(_dice_b, _dice_a[0])
  horizontal_roll(_dice_b, _dice_a[1])
else
  horizontal_roll(_dice_b, _dice_a[0])
  vertical_roll(_dice_b, _dice_a[0])
  horizontal_roll(_dice_b, _dice_a[1])
end

puts _dice_a == _dice_b ? "Yes" : "No"

