Ques link: https://hack.codingblocks.com/contests/c/547/829
Code link : https://ide.codingblocks.com/s/43110
SPP: SPOJ ---Getting Wrong answer in testcase 2 and 5 on submission on hackerblocks
Can you show your Matrix by Drawing it on paper and sharing the screenshot.
and you are doing (T,n-1) . Check whether you need to make it upto (n-1) power or something else according to your matrix.
I am also having the same problem. if your doubt is solved @deathman1198. can u please share the link to your code.