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 .

  [1]: http://www.codechef.com/problems/STFM/
  [2]: http://www.codechef.com/viewplaintext/7102192

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 * , % .

//