Answer: Immediately after the collision, \(P\) has speed \(\boxed{\dfrac{3}{\sqrt2}\sqrt{ag}}\), \(Q\) has speed \(\boxed{\sqrt{2ag}}\), and \(\boxed{\cos\theta=\dfrac56}\).
(i) First find the speed of \(P\) just before the collision at the lowest point. Call this speed \(u_P\).
From \(A\) to the lowest point, \(P\) drops a vertical distance \(a\). By conservation of energy,
\[\frac12m u_P^2=\frac12m\left(\frac{21}{2}ag\right)+mga.\]
So
\[u_P^2=\frac{21}{2}ag+2ag=\frac{25}{2}ag,\]
and hence
\[u_P=\frac5{\sqrt2}\sqrt{ag}.\]
The speed given to \(Q\) is just enough for \(Q\) to rise from the lowest point to \(B\), a vertical height \(a\). If this speed is \(v_Q\), then
\[\frac12(4m)v_Q^2=4mga.\]
Therefore
\[v_Q^2=2ag,\qquad v_Q=\sqrt{2ag}.\]
During the collision, momentum is conserved along the tangent at the lowest point.
Take the initial direction of motion of \(P\) as positive. Since \(P\) rebounds, its velocity after the collision is in the negative direction. Let its speed after the collision be \(v_P\). Then
\[m u_P=-m v_P+4m v_Q.\]
So
\[v_P=4v_Q-u_P.\]
Substitute the values:
\[v_P=4\sqrt{2ag}-\frac5{\sqrt2}\sqrt{ag}=\left(\frac8{\sqrt2}-\frac5{\sqrt2}\right)\sqrt{ag}.\]
Thus
\[v_P=\frac3{\sqrt2}\sqrt{ag}.\]
(ii) Now consider the later motion of \(P\) after it has rebounded. Let \(V\) be its speed at the point \(D\), where it loses contact.
At \(D\), the point is \(a\cos\theta\) above \(O\). From the lowest point to \(D\), the vertical rise is
\[a+a\cos\theta=a(1+\cos\theta).\]
Using energy from just after the collision to \(D\),
\[\frac12mV^2=\frac12m\left(\frac92ag\right)-mga(1+\cos\theta).\]
So
\[V^2=\frac92ag-2ag(1+\cos\theta).\]
This simplifies to
\[V^2=\left(\frac52-2\cos\theta\right)ag.\]
At the instant \(P\) loses contact, the normal reaction is zero. Resolving radially towards the centre gives
\[\frac{mV^2}{a}=mg\cos\theta.\]
Hence
\[V^2=ag\cos\theta.\]
Equate the two expressions for \(V^2\):
\[\left(\frac52-2\cos\theta\right)ag=ag\cos\theta.\]
Cancel \(ag\):
\[\frac52=3\cos\theta.\]
Therefore
\[\boxed{\cos\theta=\frac56}.\]