12. (1994 American Mathematical Invitational) A one-person card game has the following rules: Place 6 pairs of distinct cards in a bag. The player draws and replaces cards from the bag at random, but when a pair is drawn, it is set aside. If the player always draws three cards, the game ends if the three cards drawn are all distinct (i.e., no pairs). Otherwise, drawing continues until the bag is empty. Let the probability that the bag is emptied be $\frac{p}{q}$, where $p$ and $q$ are relatively prime positive integers. Find $p+q$.
12. Suppose there are $n$ pairs of distinct cards in a backpack, where $n \geqslant 2$, then the probability that 2 out of the first 3 cards drawn form a pair is

The number of ways to draw 3 cards with 2 forming a pair
The number of ways to draw 3 cards
$$
\begin{array}{l}
=\frac{C_{n}^{1} \cdot C_{2 n-2}^{1}}{C_{2 n}^{3}} \\
=\frac{3}{2 n-1} .
\end{array}
$$

Let $P(n)$ be the probability that the backpack is emptied when starting to draw cards according to the rule, given that there are $n$ pairs of distinct cards in the backpack. Clearly,
$$
\left\{\begin{array}{l}
P(2)=1, \\
P(n)=\frac{3}{2 n-1} \cdot P(n-1), n \geqslant 3 .
\end{array}\right.
$$

By repeatedly using this recursive formula, we get
$$
P(n)=\frac{3}{2 n-1} \cdot \frac{3}{2 n-3} \cdots \cdot \frac{3}{5} \cdot P(2) \text {. }
$$

Let $n=6$, then
$$
P(6)=\frac{3}{11} \cdot \frac{3}{9} \cdot \frac{3}{7} \cdot \frac{3}{5} \cdot P(2)=\frac{9}{385} .
$$

Thus, $\frac{p}{q}=\frac{9}{385}$.
Therefore, $p+q=9+385=394$.