Theory:

Factorisation by grouping the terms and then taking terms commonly outside
The terms of a given expression are need to be grouped suitably in such a way that they have a common factor so that the factorisation is easy to take out common factor
from those terms.
 
Consider the expression 3m2+mn+3mn+n2.
 
Let us take the common factor for the first two terms separately and take the common factor second two terms separately.
 
3m2+mn¯+3mn+n2¯
 
=m(3m+n)+n(3m+n)
 
=(3m+n)(m+n)