@n = gets.split(' ').map(&:to_i)
m = gets.split(' ').map(&:to_i)

def throw(a, b)
    temp = @n[0]
    @n[0] = @n[a]
    @n[a] = @n[5]
    @n[5] = @n[b]
    @n[b] = temp
end

while (m[1] != @n[0])
    throw(4, 1)
    break if m[1] == @n[0]
    throw(2, 3)
end
throw(4, 1)
while (m[0] != @n[0])
    throw(2, 3)
end
puts @n == m ? 'Yes' : 'No'