class Dice
	def initialize()
		# top bottom N E S W
		@number = gets.split.map(&:to_i)

		@dice_number = [1, 6, 5, 3, 2, 4]
	end

	def rotate(command)
		swap_number = []

		case command
		when 'N'
			swap_number = [2, 1, 4]
			swap(swap_number)
		when 'E'
			swap_number = [3, 1, 5]
			swap(swap_number)
		when 'S'
			swap_number = [4, 1, 2]
			swap(swap_number)
		when 'W'
			swap_number = [5, 1, 3]
			swap(swap_number)
		end
	end

	def rotate_horizontal
		tmp = @dice_number[2]
		(2..4).each {|i| @dice_number[i] = @dice_number[i+1]}
		@dice_number[5] = tmp
	end

	def swap(number)
		number.map do |n|
			@dice_number[0], @dice_number[n] = @dice_number[n], @dice_number[0]
		end
	end

	def dice_element(position)
		# puts "p:#{position} dice:#{@dice_number[position]} number:#{@number[@dice_number[position]-1]}"

		@number[@dice_number[position]-1]
	end

	def dice_number_element(position)
		@dice_number[position]
	end

	def number
		@number
	end

	def dice_number
		@dice_number
	end
end

def rotateToTop(dice, position)
#	puts dice.methods

	case position
	when 0
	when 1
		dice.rotate('N')
	when 2
		dice.rotate('W')
	when 3
		dice.rotate('E')
	when 4
		dice.rotate('S')
	when 5
		2.times { dice.rotate('S') }
	end
end

dice1 = Dice.new
dice2 = Dice.new

rotate_position1, rotate_position2 = 0, 0
loop_flag = false
dice1.number.map do |d1|
	dice2.number.map do |d2|
		# puts "#{d1} #{d2}"
		if (d1 == d2) then
			loop_flag = true
			break
		end
		rotate_position2 += 1
	end
	break if loop_flag
	rotate_position1 += 1
end

# puts "before"
# p dice1.dice_number
# p dice2.dice_number

# puts "position"
# puts rotate_position1
# puts rotate_position2

rotateToTop(dice1, rotate_position1)
rotateToTop(dice2, rotate_position2)

# puts "after"
# p dice1.dice_number
# p dice2.dice_number
# (0..5).each { |e| print dice2.dice_element(e) }

rotate_horizontal_count = 0
loop_flag = false
(2..5).each do |e1|
	(2..5).each do |e2|
		 # puts "#{dice1.dice_number_element(e1)} #{dice2.dice_number_element(e2)}"

		if dice1.dice_number_element(e1) == dice2.dice_number_element(e2) then
			rotate_horizontal_count = (e1 - e2).abs
			loop_flag = true
			break
		end
	end
	break if loop_flag
end

# p dice1.dice_number
# p dice2.dice_number

rotate_horizontal_count.times do
	dice1.rotate_horizontal
end

# p dice1.dice_number
# p dice2.dice_number


flag = true
(0..5).each do |e|
	# puts "#{dice1.dice_element(e)} #{dice2.dice_element(e)}"
	if dice1.dice_element(e) != dice2.dice_element(e) then
		flag = false
	end
end

if flag then
	puts 'Yes'
else
	puts 'No'
end