Respuesta :

Input
Output
(Sorry for not being detailed)