Let $F(p,d)$ denotes the set of all functions from $\{1,\cdots,p\}$ into $\{1,\cdots,d\}$.
Consider the following map $G:F(q,d)\times F(p,d) \to F(p+q,d): (f,h) \mapsto f \star h$, where $f\star h\in F(p+q,d)$ such that $(f\star h)(j) = f(j)$ for all $1\leq j\leq q$ and $(f\star h)(q+j)=h(j)$ for every $1\leq j\leq p$.
What is the inverse of G?
It is basically written down in your question. The inverse shoud map $h\in F(q+p,d)$ to $(f,g)\in F(q,d)\times F(p,d)$ with $$f(i) = h(i) \quad\text{ and }\quad g(i)=h(i+q).$$