https://www.codechef.com/NPLQ2019/problems/NPLQ19F

https://www.codechef.com/NPLQ2019/problems/NPLQ19F

Can anyone help me with this question