Let f(x) = x2+px+q
And q(x) = x2+mx+n
(x + a) is a factor of f(x) and g(x)
By remainder theorem,
f(−a)=(−a)2+p(−a)+q=0
⇒a2−ap+q=0 ...(i)
Also,
g(−a)=(−a)2+m(−a)+n=0
⇒a2−am+n=0 ...(ii)
Subtracting (ii) from (i)
-a( p - m) + q - n = 0
⇒−a(p−m)=−(q−n)⇒a(p−m)=q−n⇒a=n−qm−p