How to solve this problem from recent Codechef Long Challenge??↵
↵
[https://www.codechef.com/DEC15/problems/MGCHPERM/](http://https://www.codechef.com/DEC15/problems/MGCHPERM/)
↵
[https://www.codechef.com/DEC15/problems/MGCHPERM/](http://https://www.codechef.com/DEC15/problems/MGCHPERM/)