Let \(P\) be the point on the curve \(y=ax^2+bx+c\) (where \(a\) is non-zero) at which the gradient is \(m\). Show that the equation of the tangent at \(P\) is \[y-mx=c-\frac{(m-b)^2}{4a}.\]

Show that the curves \(y=a_1x^2+b_1x+c_1\) and \(y=a_2x^2+b_2x+c_2\) (where \(a_1\) and \(a_2\) are non-zero) have a common tangent with gradient \(m\) if and only if \[(a_2-a_1)m^2+2(a_1b_2-a_2b_1)m+4a_1a_2(c_2-c_1)+a_2b_1^2-a_1b_2^2=0.\]

Show that, in the case \(a_1\neq a_2\), the two curves have exactly one common tangent if and only if they touch each other. In the case \(a_1=a_2\), find a necessary and sufficient condition for the two curves to have exactly one common tangent.