Solution (source code)

= Solution

Let $q$ be the transferred fuel <mass>. Before any engine reversal, rocket A has <mass> $a=m_A+M-q$ and <velocity>
$$
v_A(q)=u_0\ln\frac{m_A+M}{m_A+M-q}.
$$
For <exhaust collection by a second rocket>, under the stipulated eventual capture of all exhaust, final <conservation of momentum> for the complete initially stationary system gives $m_Av_{Af}+(m_B+M)v_{Bf}=0$. Thus
$$
\boxed{v_{Af}=u_0\ln\frac{m_A+M}{m_A},\quad v_{Bf}=-\frac{m_A}{m_B+M}v_{Af},\quad v_{\rm rel}=u_0\frac{m_A+m_B+M}{m_B+M}\ln\frac{m_A+M}{m_A}.}
$$
Capture is inelastic: no <kinetic energy> conservation for B is assumed. Finite exhaust flight time changes the intermediate sharing of <momentum> but not this endpoint balance if the stated complete capture actually occurs.

The <ballistic exhaust interception condition> is a physical restriction on that idealization. For purely ballistic exhaust to reach a receding collector to the rear, its laboratory <velocity> must be more negative than B's while interception occurs. In the negligible-flight-time approximation this requires $v_A-u_0<v_B$. Very large fuel ratios need not meet that condition throughout a complete burn; the boxed endpoint formula is conditional on the prompt's complete-collection stipulation, not an unconditional prediction for every ballistic two-rocket geometry.