void pow(int k,Matrix a)
{
tpow=e; //e为单位矩阵
for(;k;a=a*a,k>>=1)
if(k&1)tpow=tpow*a;
}
Matrix sum(int k,Matrix a)
{
if(k==1) return a;
Matrix tmp=sum(k/2,a);
if(k&1)
{
pow(k/2+1,a);
tmp=tmp+tmp*tpow+tpow;
}
else
{
pow(k/2,a);
tmp=tmp+tmp*tpow;
}
return tmp;
}