Solution (source code)

= Solution

Write $K=\mathbb Q(\mu_m)$, $L=\mathbb Q(\mu_n)$. For coprime $m,n$, <Bézout's identity> and powers of a primitive $mn$-th root give $KL=\mathbb Q(\mu_{mn})$. The degrees of these <cyclotomic fields> are $\varphi(m)$, $\varphi(n)$ and $\varphi(mn)=\varphi(m)\varphi(n)$. The natural restriction map
$$
\operatorname{Gal}(KL/\mathbb Q)\longrightarrow\operatorname{Gal}(K/\mathbb Q)\times\operatorname{Gal}(L/\mathbb Q)
$$
is injective and, by these orders, bijective. Under this product description the <subgroups> fixing $K$ and $L$ are the two complementary factors. Together they generate the whole group, so their common fixed field is $\mathbb Q$. By the <Fundamental theorem of Galois theory>, \b[$K\cap L=\mathbb Q$]. This also includes $m=1$ or $n=1$.