help in understanding matrix expo. in problem 351C

prob : Problem - C - Codeforces

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 CodeChef: Practical coding for everyone

@gyanendra371 My idea’s explanation : L56AVG - EDITORIAL - #4 by pk301 - editorial - CodeChef Discuss