Mint a[7]{1},e[];ll@k;rep(k){ll@d,@l,x=3**(l%6);e[0..6]=a[0..];a[((0..6)*x+d*~-x/2)%7]+=e[0..];}wt(sum[i,1,7](a[i]*i));