partially correct

https://www.codechef.com/viewsolution/60894124

Check the following fully correct solution.

Accepted