A card shuffling machine always rearranges the cards in the same way relative to their initial order in one step. We placed the 13 spade cards in ascending order from 2 to Ace. The machine shuffled the cards once, and we put the resulting deck back in, which the machine shuffled again, then dealt out the 13 cards in the following order:

Jack, 10, King, 9, Ace, $4,5,2,6$, Queen, $7,3,8$.

What was the order of the cards after the first shuffle?
(For the notation of permutations and some basic properties of permutation groups, see József Pelikán's article "Permutation Groups" in issue 1991/4.)

Let $\pi(i)$ be the number of the position to which the $i$-th card is moved during a shuffle $(i=1,2, \ldots, 13) ; \pi$ is a permutation of the numbers $1,2, \ldots, 13$.

Since the $i$-th card is moved to the $\pi(i)$-th position during the first shuffle, and from there to the $\pi(\pi(i))$-th position during the second shuffle, the permutation corresponding to the double shuffle is $\pi^{2}$. According to the problem statement:

\[
\begin{aligned}
& \pi^{2}=\left(\begin{array}{ccccccccccccc}
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 \\
8 & 12 & 6 & 7 & 9 & 11 & 13 & 4 & 2 & 1 & 10 & 3 & 5
\end{array}\right)= \\
& =\left(\begin{array}{lllllllllllll}
1 & 8 & 4 & 7 & 13 & 5 & 9 & 2 & 12 & 3 & 6 & 11 & 10
\end{array}\right) .
\end{aligned}
\]

We can see that $\pi^{2}$ is a single cycle of length 13. This implies that $\pi$ also consists of a single cycle, because if $\pi$ consisted of at least 2 (even single-element) cycles, then $\pi^{2}$ would also have at least two cycles. Let $\pi=\left(1 a_{1} a_{2} \ldots a_{12}\right)$, then $\pi^{2}=\left(\begin{array}{llllllllll}1 & a_{2} & a_{4} & a_{6} & \ldots & a_{10} & a_{12} & a_{1} & a_{3} & a_{5} \\ \ldots & a_{11}\end{array}\right)$. Comparing this with (1), we get that $a_{2}=8, a_{4}=4, a_{6}=$ $7, a_{8}=13, a_{10}=5, a_{12}=9, a_{1}=2, a_{3}=12, a_{5}=3, a_{7}=6, a_{9}=11, a_{11}=10$, thus

\[
\begin{aligned}
& \pi=\left(\begin{array}{lllllllllllll}
1 & 2 & 8 & 12 & 4 & 3 & 7 & 6 & 13 & 11 & 5 & 10 & 9
\end{array}\right)= \\
& =\left(\begin{array}{ccccccccccccc}
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 \\
2 & 8 & 7 & 3 & 10 & 13 & 6 & 12 & 1 & 9 & 5 & 4 & 11
\end{array}\right)
\end{aligned}
\]

The order of the cards after the first shuffle: 10, 2, 5, King, Queen, 8, 4, 3, Jack, 6, Ace, 9, 7.

Remark. Since $\pi$ is a cycle of length 13, $\pi$ can also be calculated from the formula $\pi=\pi^{13} \cdot \pi=\left(\pi^{2}\right)^{7}$.