The target is to simulate a discrete random variable $Z$ with mass function satisfying $\mathbb{P}(Z=i)\propto \pi_i$, for $i\in S$ and $S$ countable.
Let $X$ be an irreducible Markov chain with state space $S$ and transition matrix $P=(p_{i,j})$ and let $Q=(q_{i,j})$ be given by $$q_{i,j} = \left\{ \begin{matrix}\mbox{min\{$p_{i,j},(\pi_j/\pi_i)p_{j,i}$\}} & if\space i\ne j, \\ \mbox{1-$\sum_{j:j\neq i}q_{i,j}$ } & if\space i=j. \end{matrix}\right.$$ How do I show that $Q$ is the transition matrix of a Markov chain which is reversible in equilibrium and has invariant distribution equal to the mass function of $Z$?
I thought about checking that $Q$ and $\pi$ are in detailed balance, but I dont know how to continue from there. I know all the definitions individually, but I dont know how to use them to prove this.