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]
	when 'CC' # Counterclockwise
		d[1], d[2], d[4], d[3] = d[3], d[1], d[2], d[4]
	end
end

def asc(d)
	min = d.min
	case d.index(min)
	when 1; roll(d, ?N)
	when 2; roll(d, ?W)
	when 3; roll(d, ?E)
	when 4; roll(d, ?S)
	when 5; roll(d, ?N); roll(d, ?N)
	end

	side_min = d[1, 4].min
	case d.index(side_min)
	when 2; roll(d, ?C)
	when 3; roll(d, 'CC')
	when 4; roll(d, ?C); roll(d, ?C)
	end

	d
end

puts asc(a) == asc(b) ? 'Yes' : 'No'