Mex ception problem doubt

My link of solution to the problem Mex ception which appeared in july cook off is pasted below .
Please help to find out what is wrong in its submission.I am getting wrong answer but not able to figure out why.Please help someone .
https://www.codechef.com/viewsolution/35837231

Gives WA on 1 1.