5. Let point $M$ divide edge $A B$ in the ratio $A M: M B=\lambda$, point $N$ divide edge $D C$ in the ratio $D N: N C=\mu$, and point $P$ divide edge $D B$ in the ratio $D P: P B=\theta$. We need to find the ratio $A Q: Q C$.

![](https://cdn.mathpix.com/cropped/2024_05_06_f36d8ea35c99389d52e3g-13.jpg?height=765&width=725&top_left_y=200&top_left_x=654)

Let $T$ be the intersection point of line $P N$ with line $B C$, then point $Q$ is the intersection point of line $M T$ with line $A C$. Let $B M=a$, $C N=b$, and $B P=c$. Then $M A=\lambda a$, $N D=\mu b$, and $P D=\theta c$.

Applying Menelaus' theorem to triangle $C B D$ and the transversal $P T$:

$$
\frac{C T}{T B} \cdot \frac{B P}{P D} \cdot \frac{D N}{N C}=1 \quad \text{or} \quad \frac{C T}{T B} \cdot \frac{1}{\theta} \cdot \mu=1.
$$

From this, we find $\frac{C T}{T B}=\frac{\theta}{\mu}$.

Now, applying Menelaus' theorem to triangle $A C B$ and the transversal $M T$:

$$
\frac{A Q}{Q C} \cdot \frac{C T}{T B} \cdot \frac{B M}{M A}=1 \quad \text{or} \quad \frac{A Q}{Q C} \cdot \frac{\theta}{\mu} \cdot \frac{1}{\lambda}=1.
$$

From this, we get

$$
\frac{A Q}{Q C}=\frac{\lambda \mu}{\theta}
$$

According to the problem, $\lambda=2$, $\mu=3$, and $\theta=\frac{1}{2}$, then $\frac{A Q}{Q C}=12$.
Answer: $A Q: Q C=12$.

#