Codechef problem RGAND( wrong answer)

Hey I was doing this problem from cook off , I think my code is correct but it is giving WA . Please if someone can provide some edge cases on which it might fail.
problem : https://www.codechef.com/problems/RGAND
submission : https://www.codechef.com/viewsolution/32341448

Thanks in advance!