Artificial intelligent assistant

How to resolve square of matrix substraction? I am currently stuck with the following step of the derivation of the Fisher criterion. Can somebody please expand and explain the following? I cannot follow the steps. $$ =\dots$$ $$= (\mathbf{w}^T\mathbf{m}_1-\mathbf{w}^T\mathbf{m}_2)^2$$ $$= \mathbf{w}^T(\mathbf{m}_1-\mathbf{m}_2)(\mathbf{m}_1-\mathbf{m}_2)^T\mathbf{w}$$ $$=\dots$$

You can show this by the following procedure

$$(w^Tm_1-w^Tm_2)^2=\left[w^T(m_1-m_2) \right]^2=w^T(m_1-m_2)w^T(m_1-m_2)$$

Now, note that $w^T(m_1-m_2)$ is a scalar (row vector $\cdot$ column vector), hence we can simply transpose it without changing it.

$$(w^Tm_1-w^Tm_2)^2=w^T(m_1-m_2)\left[w^T(m_1-m_2)\right]^T=w^T(m_1-m_2)(m_1-m_2)^Tw.$$

In the last step I used $(AB)^T=B^TA^T$.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 7a80071f48aa3cac42cb632ae994bc38