5. Two boxes are filled with black and white balls. The total number of balls in both boxes is 25. Each time, a ball is randomly drawn from each box. The probability that both balls are black is $\frac{27}{50}$, and the probability that both balls are white is $\frac{m}{n}\left(m, n \in \mathbf{Z}_{+},(m, n)=1\right)$. Then $m+n=$ $\qquad$ .
5.26.

Let the first box contain $x$ balls, of which $p$ are black, and the second box contain $25-x$ balls, of which $q$ are black. Then
$$
\begin{array}{l} 
\frac{p}{x} \cdot \frac{q}{25-x}=\frac{27}{50}, \\
50 p q=27 x(25-x) .
\end{array}
$$

Thus, $x$ is a multiple of 5.
Substituting $x=5$ and $x=10$ into the two equations, we get
$$
\begin{array}{l}
x=5, p=3, q=18 ; \\
x=10, p=9, q=9 .
\end{array}
$$

For both cases, $\frac{m}{r_{0}}=\frac{1}{25}$. Therefore, $m+n=26$.