Three players: $A, B$, and $C$ play the following game: on each of three cards, an integer is written. For these three numbers $(p, q$, and $r)$, it holds that $0<p<q<r$.

The cards are shuffled and then distributed so that each player gets one. Then, the players are given as many marbles as the number on their card. After that, the cards are collected, but the marbles remain with the players.

This game (shuffling the cards, distributing them, giving the marbles, and collecting the cards) is played at least twice. After the last game, $A$ has 20, $B$ has 10, and $C$ has 9 marbles. Additionally, $B$ knows that on the last occasion, they received $r$ marbles.

Who received $q$ marbles for the first time?
Since in every game $p+q+r$ balls were distributed, and after the last game the number of distributed balls is $20+10+9=39$, therefore 39 is divisible by $p+q+r$. $010$; thus

$$
2 p+r=10
$$

The number of $C$'s balls is 9, so $C$ could not have received $r$ balls, since (2) already indicates that $p+p+r$ is more than 9. Therefore, on the other two occasions, $A$ received the $r$ balls.

Since player $B$ received $r$ balls last, $A$ won $r$ balls in the first and second games. $B$ won $p$ balls in the first and second games, but then $q$ balls were first received by $C$.

The values of $p, q$, and $r$ can also be calculated from the data, although this is not the question of the problem. $A$ won either $p$ or $q$ balls in the third game, depending on which, we can write for the number of $A$ and $C$'s balls that

$$
\begin{array}{ll}
q+q+q=9 & r+r+p=20 \\
q+q+p=9 & r+r+q=20
\end{array}
$$

Comparing these with (2), from (3a) we get $p=0, q=3, r=10$, which cannot be because of $0<p$. From (3b) we get $p=1, q=4$, $r=8$, and at the same time we have also obtained that the sequence of games described in the problem can indeed occur:

|  | A | B | C |
| ---: | ---: | ---: | ---: |
| I. game: | 8 | 1 | 4 |
| II. game: | 8 | 1 | 4 |
| III. game: | 4 | 8 | 1 |