\(B=\left(a-1\right)^3-4a\left(a+1\right)\left(a-1\right)+3\left(a-1\right)\left(a^2+a+1\right)\)
\(=a^3-3a^2+3a-1-4a^3+4a+3a^3-3\)
\(=7a-4=7\left(-3\right)-4=-25\)
\(B=\left(a-1\right)^3-4a\left(a+1\right)\left(a-1\right)+3\left(a-1\right)\left(a^2+a+1\right)\)
\(=a^3-3a^2+3a-1-4a\left(a^2-1\right)+3\left(a^3-1\right)\)
\(=a^3-3a^2+3a-1-4a^3+4a+3a^3-3\)
\(=-3a^2+7a-4\)
\(=-3\cdot\left(-3\right)^2+7\cdot\left(-3\right)-4\)
\(=-3\cdot9-7\cdot3-4\)
\(=-27-21-4=-48-4=-52\)