a, b = 2.times.map{ gets.split.map(&:to_i) }

def roll(d, cmd)
	case cmd
	when ?E
		d[0], d[2], d[5], d[3] = d[3], d[0], d[2], d[5]
	when ?N
		d[0], d[1], d[5], d[4] = d[1], d[5], d[4], d[0]
	when ?S
		d[0], d[1], d[5], d[4] = d[4], d[0], d[1], d[5]
	when ?W
		d[0], d[2], d[5], d[3] = d[2], d[5], d[3], d[0]
	when ?C # clockwise
		d[1], d[2], d[4], d[3] = d[2], d[4], d[3], d[1]
	end
end

def _same?(a, b)
	return false if a[0] != b[0]

	4.times do
		return true if a == b
		roll(b, ?C)
	end

	return false
end

def same?(a, b)
	return false if a.sort != b.sort

	return true if _same?(a, b)
	%w[N E E E N].each do |c|
		roll(b, c)
		return true if _same?(a, b)
	end

	return false
end

puts same?(a, b) ? 'Yes' : 'No'