Solution (source code)

= Solution

Take <context-free grammar>[context-free grammars] $G_L,G_M$ for $L,M$ and rename their nonterminals so that they are disjoint. If their start symbols are $S_L,S_M$, add a new start symbol $S$ and the production
$$
S\to S_LS_M.
$$
All productions remain context-free. A derivation from $S$ produces a word from $L$ followed by a word from $M$, and every such concatenation has a derivation. Thus the new grammar generates $LM$, proving <closure of context-free languages under concatenation>.