Why can the map between fundamental groups be extended to the whole polygon?

Let $$M$$ be a surface with genus $$g$$. Suppose there is an injection $$\pi_1(M) \to \pi_1(N)$$, where $$N^2$$ is compact and oriented. We can view $$M$$ as a $$4g$$-sided polygon with appropriate identification and defining a boundary map via the inclusion $$\pi_1(M) \to \pi_1(N)$$. I am wondering why this allows me to extend the map $$\phi:M \to N$$. The hint I am given is to use contractibility, but I am not very sure how to use this hint.

Let's call

• $$P$$ your $$4g$$-gon;
• $$f:P → M$$ the quotient map;
• $$\hat\gamma:[0,1] → \partial P$$, a simple loop circumnavigating $$\partial P$$;
• $$\gamma= f\circ \hat\gamma$$, the image onto $$M^1$$; and
• $$a_1,b_1,\ldots,a_g,b_g:S^1→ M^1$$ the loops generating $$\pi_1(M)$$, such that $$\gamma = [a_1,b_1][a_2,b_2]\cdots[a_g,b_g].$$

Let $$\phi_\ast$$ denote your homomorphism, and $$\phi$$ the map to be derived.

Choosing representatives of the images of the generators $$\phi_\ast(a_i),\ \phi_\ast (b_i)$$ gives a map $$M^1→N$$ as you mention: $$\phi:\bigcup a_i\cup b_i → \bigcup \phi(a_i)\cup \phi(b_i) \tag(1)$$ The fact that $$\phi_\ast$$ is a homomorphism then tells us that

$$[\phi(a_1),\phi(b_1)][\phi(a_2),\phi(b_2)]\cdots[\phi(a_g),\phi(a_g)]$$

is nullhomotopic in $$N$$, since it represents the class

$$\phi_\ast([a_1,b_1][a_2,b_2]\cdots[a_g,b_g]) = \phi_\ast (1_{\pi_1(M)}) = 1_{\pi_1(N)}.$$

Let $$F: S^1 × [0,1] → N$$ denote the nullhomotopy. I.e.:

• $$F$$ is continuous.
• $$F(\cdot, 1) = [\phi(a_1),\phi(b_1)][\phi(a_2),\phi(b_2)]\cdots[\phi(a_g),\phi(a_g)]$$.
• $$F(\cdot, 0)$$ is constant.

By the last bullet point, $$F$$ passes to the quotient to give a map

$$F: \frac{S^1 × [0,1]}{S^1 × \{0\}} → N,$$

Theis new domain of $$F$$ is, up to homeomorphism your polygon (a.k.a. disk): i.e. there exists a homeomorphism

$$\Psi:P → \frac{S^1 × [0,1]}{S^1 × \{0\}}.$$

One just has to show that $$\Psi$$ can be chosen so that $$F\circ\Psi: P \to N$$ passes again to the quotient $$f$$ to give a continuous map $$M → N$$.

This is a condition only on the restriction of $$\Psi$$ from boundary to boundary: $$\partial P → S^1 × \{1\}$$. Since $$\gamma$$ is simple, we can take

$$\Psi^{-1}(x,1) = \gamma(x)$$

and this does the trick nicely—from the second point about $$F$$, it follows that $$\Psi \circ F$$ restricted to $$\partial P$$ is equal to the function $$\phi$$ as in $$(1)$$, and so easily passes to the quotient, as required!