How to solve RECTARAN?

https://www.codechef.com/APRIL19A/problems/RECTARAN