WA in NEXTNUM(rank of a number)

can anyone tell me for what testcase my code is giving WA…
link…CodeChef: Practical coding for everyone

You can ask it in the editorial of the problem here : NEXTNUM - Editorial - editorial - CodeChef Discuss