Permutation Shuffle : Getting Wrong Answer

Hi,
Can anyone please check my solution. I am getting wrong answer.
Please suggest a test case where it is failing.
Link to Question:http://www.codechef.com/problems/PERMSUFF
Link to solution : http://www.codechef.com/viewsolution/4675027