Solution (source code)

= Solution

The assumed identities are the <detailed balance equations>. Summing over $i$ and using the row sums of the <transition matrix> gives, for every $j$,
$$
(\pi P)_j=\sum_i\pi_ip_{i,j}=\sum_i\pi_jp_{j,i}=\pi_j\sum_ip_{j,i}=\pi_j.
$$
All summands are nonnegative, so these countable sums are justified. Thus
$$
\boxed{\pi P=\pi,}
$$
and $\pi$ is an <invariant distribution>.