Compute expected received balls from boxes I have 6 boxes: $A,B,A',B',C \text{ and } D$. The box $A$ has $n_1$ red balls that are numbered from $1, \cdots, n_1$. The box $B$ has $n_2$ green balls that are numbered from $1, \cdots, n_2$. Make a copy version of these boxes $A,B$  are $A',B'$ (It means the box $A'$ has $n_1$ red balls from $1, \cdots, n_1$, and the box $B'$ has $n_2$ green balls from $1, \cdots, n_2$ ). These two boxes $C,D$ have no balls. Let $p$ be loss probability when we throw balls from a box to another box (each ball gets dropped with independent probability $p$). (For example, if we throw a ball from the box $A$ to box $C$ with loss prob. is $p=10\%$, then $90\%$ the ball will not drop. Then expected number of received ball in box $C$ will be $0.9n_1$ balls...).
First, I will throw these balls from $A$ and $B$ to the box $C$ with loss probability is $p$. Call number of red and green balls in box $C$ are $n_{1C},n_{2C}$, respectively. Then, randomly select $r$ balls from the box $C$, with $0 \le r \le \min(n_1,n_2,n_{1C}+n_{2C})$. Throw these $r$ balls to the box $D$ with loss probability $p$.
Second, throw these balls from these boxes $A',B'$ to the box $D$ with loss probability $p$.
How many (expected number) red balls do we have in the box $D$ in term of $p$, if two red balls have the same number (i.e number 4 of a red ball from $A' \to D$, and number 4 of a red ball from $C \to D$), then the red ball only counts 1 time? In the same manner, how many green balls do we have in the box $D$? Thank you in advance.

 A: NOTE:  as the OP points out in the comments, this solution incorrectly assumes that ALL balls in $C$ are subsequently tossed over towards $D$.  That case may still be relevant so I will leave this up for now and will modify it if I can incorporate the filter from $C$.
Let $X_i$ denote the indicator variable for the $i^{th}$ red ball.  Thus $X_i=1$ if $r_i$ eventually gets to box $D$ (either once or twice) and $X_i=0$ otherwise.  Let $E[Red]$ be the expected number of red balls that eventually make it to $D$.  Then by linearity of expectation $$E[Red]=E\left[\sum X_i\right]=\sum E[X_i]=\phi\times n_1$$  Where $\phi$ denotes the probability that a given red ball makes it (either once or twice).  It's easy to compute $\phi$.  The chosen ball makes it along the path $A'\to D$ with probability $q=1-p$ and it makes it there along the path $A\to C \to D$ with probability $q^2$.  Adding these double counts those cases in which the ball makes it via both routes, which happens with probability $q^3$.  Thus $$\phi=q+q^2-q^3\implies E[Red]=(q+q^2-q^3)\times n_1$$
The same argument shows that $E[Green]=(q+q^2-q^3)\times n_2$  and the final answer is just $$E=E[Red]+E[Green]=(q+q^2-q^3)\times (n_1+n_2)$$
