Mint a[7]{1},e[];ll@k,b[]{0,1,4,6,5,2},c[]{1,3,2,6,4,5};rep(k){ll@d,@l;e[0..6]=a[0..];a[((0..6)*c[l%6]+d*b[l%6])%7]+=e[0..];}wt(sum[i,1,7](a[i]*i));