I want some help for the following exercise
I know that the leaving variable is the basic variable associated with the smallest nonnegative ratio with the strictly positive denominator. I can't understand how the current basic variables ($x_5$, $x_6$, $x_7$, $x_8$) are matched with the equations.

Let $x_r$ and $x_j$ denote the leaving and entering variables respectively. ($r$ stands for "row"; $j$ runs through columns.)
Write the simplex tableaux. $$ \require{enclose} % inner horizontal array of arrays \begin{array}{cc} % inner array of minimum values \begin{array}{r|r|r|r} \text{basis} & a_j & b & b/a_j \\ \hline 5 & 1 & 4 & 4 \\ 6 & 5 & 8 & 8/5 \\ \to7 & 2 & 3 & \enclose{circle}{3/2} \\ 8 & * & 0 & - \end{array} & % inner array of minimum values \begin{array}{r|r|r|r} \text{basis} & a_j & b & b/a_j \\ \hline 5 & 2 & 4 & 2 \\ 6 & * & 8 & - \\ \to7 & 3 & 3 & \enclose{circle}{1} \\ 8 & * & 0 & - \end{array} \\ j=1,r=7 & j=2,r=7 \\ % inner array of minimum values \begin{array}{r|r|r|r} \text{basis} & a_j & b & b/a_j \\ \hline 5 & * & 4 & - \\ 6 & * & 8 & - \\ 7 & * & 3 & - \\ \to8 & 1 & 0 & \enclose{circle}{0} \end{array} & % inner array of minimum values \begin{array}{r|r|r|r} \text{basis} & a_j & b & b/a_j \\ \hline \to5 & 5 & 4 & \enclose{circle}{4/5} \\ 6 & 6 & 8 & 4/3 \\ 7 & 3 & 3 & 1 \\ 8 & * & 0 & - \end{array} \\ j=3,r=8 & j=4,r=5 \end{array} $$ Fix $j$. Observe that $r$ is the index which minimises $\{b/a_{rj} \mid a_{rj}>0 \}$. (You may refer to a theoretical explanation for such choice.)