I need to solve a similar problem, so I am going to solve both of them (this one and the one that I need to solve) at once