RADGEE Question WA

Question --> https://www.codechef.com/FLPAST01/problems/RADGEE
In the above question it is mentioned “The game continues on until all cards are discarded”. What will happen for the case when M>N .

My solution–> https://codeshare.io/mycode1

It is giving WA . Can someone tell me the reason ?