Solution (source code)

= Solution

A path with $n$ visits makes $n$ departures from $B$ and $n$ departures from $I$. Its conditional mean duration is therefore $n(\tau_B+\tau_I)$. Averaging over the <geometric distribution>,
$$
\boxed{T_{AB}=\sum_{n=1}^{\infty}n(\tau_B+\tau_I)q^{n-1}p.}
$$
Only the mean waiting times are needed here: <linearity of expectation> adds their contributions without requiring each residence time to equal its mean.