\(=\left(x^2-3x-1\right)^2-12\left(x^2-3x-1\right)+36-9\\ =\left(x^2-3x-1-6\right)^2-9\\ =\left(x^2-3x-7-3\right)\left(x^2-3x-7+3\right)\\ =\left(x-5\right)\left(x+2\right)\left(x-4\right)\left(x+1\right)\)
\(\left(x^2-3x-1\right)^2-12\left(x^2-3x-1\right)+27\)
\(=\left(x^2-3x-4\right)\left(x^2-3x-10\right)\)
\(=\left(x-4\right)\left(x+1\right)\left(x-5\right)\left(x+2\right)\)