help in understanding matrix expo. in problem 351C

prob :

I’ve read the editorial but didn’t understand the matrix exponentiation part. can someone please explain that part.

hey i tried but didn’t get it.
but u can help me by explaining ur chef and average on a tree.
ur soln link

@gyanendra371 My idea’s explanation :