\(M=\left(\dfrac{x-x^2}{\left(x-1\right)^2}+\dfrac{1}{1+x}-\dfrac{x}{x-1}\right)\cdot\left(\dfrac{3x-1}{x}+\dfrac{1}{x+1}-1\right)\)
\(=\left(\dfrac{-x}{x-1}-\dfrac{x}{x-1}+\dfrac{1}{x+1}\right)\cdot\dfrac{\left(3x-1\right)\left(x+1\right)+x-x\left(x+1\right)}{x\left(x+1\right)}\)
\(=\dfrac{-2x\left(x+1\right)+x-1}{\left(x-1\right)\left(x+1\right)}\cdot\dfrac{3x^2+2x-1+x-x^2-x}{x\left(x+1\right)}\)
\(=\dfrac{-2x^2-2x+x-1}{\left(x-1\right)\left(x+1\right)}\cdot\dfrac{2x^2+2x-1}{x\left(x+1\right)}\)
\(=\dfrac{-2x^2-x-1}{\left(x-1\right)\left(x+1\right)}\cdot\dfrac{2x^2+2x-1}{x\left(x+1\right)}\)
\(=\dfrac{\left(-2x^2-x-1\right)\left(2x^2+2x-1\right)}{x\left(x+1\right)^2\cdot\left(x-1\right)}\)