Solution (source code)

= Solution

Let $g_i'=g\Delta\rho_i/\rho$ denote the density deficit of each warm layer relative to outside. The integrated hydrostatic driving head is
$$
\mathcal H=g_1'(h_2-h_1)+g_2'(H-h_2).
$$
The same pair of orifice laws therefore gives
$$
\boxed{Q_b=Q_t=Q=A^*\sqrt{\mathcal H}.}
$$
Both plumes remove fluid from the lower layer. If $q_1=CB_1^{1/3}h_1^{5/3}$ and $q_{21}=CB_2^{1/3}h_1^{5/3}$ are their fluxes at its upper interface, lower-layer conservation also gives
$$
\boxed{Q=q_1+q_{21}=C(B_1^{1/3}+B_2^{1/3})h_1^{5/3}.}
$$
In steady state the weak plume supplies the middle layer, while the strong plume entrains that supply above $h_1$ and carries the total volume into the upper layer. Consequently $Q_2(h_2)=Q$ and $g_2'Q=B_1+B_2$. These balances assume the plumes remain spatially separate and wall heat loss is negligible.