Rec seq version 2 wrong ans

my code https://ide.codingblocks.com/#/s/31561
ques link https://hack.codingblocks.com/contests/c/528/829

To avoid overflow, you needa do C[i][j]=(C[i][j] + A[i][x]*B[x][j])%MOD and res=(res+(T[0][i]*b[i]))%MOD

sir i have already taken the mod in both the cases

You’ve done x += y%MOD but still x may overflow, right?
So do x = (x + y)%MOD