I get wrong answer after taking mod

I have used Matrix Exponentiation to solve this problem as suggested in Hint video. I got the correct answer before taking MOD, It gives wrong answer otherwise…
my code: ide.codingblocks.com/s/289740

@sufia.aleena12 define value of the mod without comma (you cant give comma in between a number)