Not passig all test cases

I’m unable to pass all the test cases.
My complexity is log(b),
I’m taking long long precautionary.

Can someone help me a bit please?

Thanks!
Link: https://ide.codingblocks.com/s/220758

you need to take modulo in the fast_exp function as well because continous multiplication of a with a could overflow the long long.

Oh, Okay right! Thanks!