I want to construct a context-free grammar for this language:
\begin{align*} L = \{uc^nd^nv\mid \ u,v \in \{a,b\}^* \text{ and the number of a's and b's in } uv \text{ are equal}\} \end{align*}
I know how to contruct a grammar for a language that has words with an equal number of a's and b's: \begin{align*} &S\to aSb \\ &S\to bSa \\ &S\to SS \\ &S\to \epsilon \end{align*} I also know how to construct $c^nd^n$: \begin{align*} &S\to cSd \\ &S\to \epsilon \end{align*} Could you give any hints how to combine these rules?