In general #(A* B )k^2+(A*Q+B*P)kn+(P*Q)n^2 = (Ak+Pn)(Bk+Qn)#
(This looks more complex than it is).
For the given expression:
#A*B = 9#
#color(white)("XXXX")#The (positive) factors of 9 are #(1,9) and (3,3)#
#color(white)("XXXX")#so we don't have too many possibilities to check.
#P*Q = 25#
#color(white)("XXXX")#The (positive) factors of 25 are #(1,25) and (5,5)#
#color(white)("XXXX")#again, there aren't a lot of possibilities.
The coefficient of the middle term
#color(white)("XXXX")##30 = 3*5 + 3*5# (using only factors determined above).
So #A=3 and B=3#
and #P=5 and Q=5#
and the general factors #(Ak+Pn)(Bk+Qn)# become
#color(white)("XXXX")##(3k+5n)(3k+5n)#