The production function
$$F(x) = x_1^{\alpha_1}x_2^{\alpha_2}x_3^{\alpha_3},$$
has the derivative with respect to $x_j$ where for sake of example I choose $j=1$
$$\frac{\partial F(x)}{\partial x_1} = \alpha_1x_1^{\alpha_1-1}x_2^{\alpha_2}x_3^{\alpha_3},$$
however, it is better (in my opinion) to write it as
$$\frac{\partial F(x)}{\partial x_1} = x_1^{\alpha_1}x_2^{\alpha_2}x_3^{\alpha_3} \frac{\alpha_1}{x_1},$$
because then the production function reappears in the derivative as the factor $x_1^{\alpha_1}x_2^{\alpha_2}x_3^{\alpha_3}$.
By setting up the Lagrangian you get first-order conditions
$$p_j = \lambda \frac{\partial F(x)}{\partial x_j} = \lambda x_1^{\alpha_1}x_2^{\alpha_2}x_3^{\alpha_3} \frac{\alpha_j}{x_j}$$
for $j=1,2,3$ and where $p_j$ is either $w$,$r$ or $q$. By using indexation you can write three equations as one (you save paper and thereby the rainforest - which is one way mathematicians are helping us be more ecofriendly).
Now it is easy to see that $\lambda$ must be positive for any non-zero production level (prices are positive, $\alpha_j$'s are positive and the production level is positive $x_1^{\alpha_1}x_2^{\alpha_2}x_3^{\alpha_3}$ is positive. Hence, the constraint must be binding $F(x) = y$.
Use this and rewrite FOC to get
$$(1) \ \ p_jx_j = \lambda y \alpha_j,$$
take the sum over $j=1,2,3$ and get
$$C= \lambda y \bar \alpha,$$
where $C=\sum_j p_j x_j$ the total costs and $\bar \alpha = \sum_j \alpha_j$ which is 1 in the case of constant returns to scale. You now know that
$$ \lambda = \frac{C}{y \bar \alpha},$$
which you can back substitute into (1) to get
$$(2) \ \ x_j = \frac{\alpha_j C}{\bar \alpha p_j},$$
you then substitute this into the constraint $F(x) = y$ to get
$$ y = \left(\frac{\alpha_1 C}{\bar \alpha p_1}\right)^{\alpha_1}\left(\frac{\alpha_2 C}{\bar \alpha p_2}\right)^{\alpha_2}\left(\frac{\alpha_3 C}{\bar \alpha p_3}\right)^{\alpha_3} =\frac{\alpha_1^{\alpha_1}\alpha_2^{\alpha_2}\alpha_3^{\alpha_3} C^{\bar \alpha}}{p_1^{\alpha_1}p_2^{\alpha_2}p_3^{\alpha_3}\bar \alpha^{\bar \alpha}},$$
implying that
$$C = \left( \frac{p_1^{\alpha_1}p_2^{\alpha_2}p_3^{\alpha_3} }{\alpha_1^{\alpha_1}\alpha_2^{\alpha_2}\alpha_3^{\alpha_3} } \right)^\frac{1}{\bar \alpha}\bar \alpha y^\frac{1}{\bar \alpha},$$
which is the cost function $C(p,y)$. You can then back insert this into (2) to get
the conditional factor demand
$$x_j = \frac{\alpha_j /\bar \alpha}{p_j} \left[\left( \frac{p_1^{\alpha_1}p_2^{\alpha_2}p_3^{\alpha_3} }{\alpha_1^{\alpha_1}\alpha_2^{\alpha_2}\alpha_3^{\alpha_3} } \right)^\frac{1}{\bar \alpha} \bar \alpha y^\frac{1}{\bar \alpha}\right],$$
where you could remove $\bar \alpha$ but the point of leaving it there is that the term in the square parenthesis is simply the cost function so it can be seen that the firm use a fixed share $\alpha_j/\bar \alpha$ of its total cost to finance us of factor $j$.