[008] Final solution for 8th problem