#!/usr/bin/env ruby

require 'set'

class Dice
	attr_reader :top, :s, :e

    def initialize(top, s, e, w, n, bottom)
        @top    = top
        @s      = s
        @e      = e
        @w      = w
        @n      = n
        @bottom = bottom
	end

	def rotate!(dist)
		@top, @s, @e, @w, @n, @bottom = 
		case dist
		when 'N' then [@s, @bottom, @e, @w, @top, @n]
		when 'S' then [@n, @top, @e, @w, @bottom, @s]
		when 'E' then [@w, @s, @top, @bottom, @n, @e]
		when 'W' then [@e, @s, @bottom, @top, @n, @w]
		end
	end
end

if __FILE__ == $0 then
	dice1 = Dice.new(*gets.split.map(&:to_i))
	dice2 = Dice.new(*gets.split.map(&:to_i))

	ref1 = Set.new()
	ref2 = Set.new()
	1000.times do
		if ref1.size > 23 then
			break
		end
		ref1.add([dice1.top, dice1.s, dice1.e])
		ref2.add([dice2.top, dice2.s, dice2.e])

		dist = 'NSEW'[rand(4)]
		dice1.rotate!(dist)
		dice2.rotate!(dist)
	end

	puts ref1==ref2 ? 'Yes' : 'No'
end

