Problem link - https://www.codechef.com/problems/JAM11/

where is this solution going wrong. i am using matrix exponentiation to calculate the nth number in the recurrence relation in log(N) time

https://www.codechef.com/viewsolution/36179316

Although it can be easily solved using O(n) approach as the contraints permits O(n) solution also. but i would like to know what’s wrong with this solution.