GUESSPRM WA

https://www.codechef.com/viewsolution/30945875
This is getting WA on most of the subtasks while some are also getting AC.

Is this due to overflow or am I missing something?