Stfm getting WA

Here is problem [STFM][1] and here is my

[2] which is giving WA for some test cases . Could not find my mistake ?Please point out my mistake .


The same happened with me. Carefully check whether there is overflow or not. Make good use of the modulus thing. I increased modulus so got AC for all

Okay , i get my mistake . it’s not overflow but operator precedence of * , % .