SPOJ PROBLEM LASTDIG

I am doing this problem by Binary Exponentiation
https://ideone.com/fork/eKonwC but it spoj showing WA
Please can somebody tell me whats with this code.Thank you in advance