All test case working, But still WA!

Guys I have used modulation as a separate function. Tested different test cases. All are working. No overflow is there. But still judge saying WA. Please Help wrt to the problem asked in cookoff yesterday named “MATBREAK”.

Here is the attached solution:
https://www.codechef.com/viewsolution/32112321