S E Q - matrix exponentiation maths help?

My solution is failing at last test case , any hint why it is so.
??