Solution (source code)

= Solution

Take all external momenta incoming, $q_1=p_1$, $q_2=p_2$, and $q_{2+r}=-k_r$. For a diagram whose middle leg is $a$ and whose two end pairs are $\{b,c\}$ and $\{d,e\}$, the <Feynman rules> give
$$
i\mathcal M_{a|bc|de}
=(-ig)^3
\frac{i}{(q_b+q_c)^2-m^2+i\epsilon}
\frac{i}{(q_d+q_e)^2-m^2+i\epsilon}.
$$
Equivalently,
$$
\mathcal M_{a|bc|de}
=-\frac{g^3}{[(q_b+q_c)^2-m^2+i\epsilon][(q_d+q_e)^2-m^2+i\epsilon]}.
$$
The full connected tree amplitude is the sum over the fifteen choices described in part d, multiplied by the overall momentum-conserving delta function from part c.