WA in MATBREAK

Can someone help me figure out what’s wrong my solution. I think it’s the correct approach. Here’s my solution :
https://www.codechef.com/viewsolution/32083957