Classifying continuous maps from closed 2-manifolds to various closed manifolds I believe my question should be simple. The question is more physically oriented and originated from one of Witten's papers, "On Holomorphic Factorization of WZW
and Coset Models", where he considered a continuous map,
$$\phi: \Sigma\rightarrow M\,,$$
where $\Sigma$ is a two-dimensional closed surface and $M$ is an arbitrary closed manifold. Witten claimed that, if 
$$\pi_1(M)=\pi_2(M)=0\,,$$
then the map $\phi$ will be automatically nullhomotopic. Denote the set $\,\mathcal{C}=\{\phi:\Sigma\rightarrow M\}$ as all continuous maps from $\Sigma$ to $M$. 
Now my question is simply that if either $\pi_1(M)$ or $\pi_2(M)$ are non-trivial. How can one argue that there would be maps in $\mathcal{C}$ NOT homotopic to identity. More generally, if assume $\Sigma$ is a 2-sphere, can one figure out the homotopy of the configuration space $\,\mathcal{C}$, say $\pi_0(\mathcal{C})$, $\pi_1(\mathcal{C})$ and $\pi_2(\mathcal{C})$ etc.
Thanks in advance!
 A: If we know that either $\pi_1(M)$ or $\pi_2(M)$ is nontrivial, indeed there does exist a homotopically nontrivial map $\Sigma \to M$ for any surface $\Sigma \neq S^2, \Bbb{RP}^2$. 
If $\pi_1(M) \neq 0$, then choose a representative $f : S^1 \to M$ of a  nontrivial homotopy class $[f]$. Let $\Sigma$ be some surface, and let $\Sigma \to T^2$ be the map given by pinching complement of a punctured torus in the connected sum decomposition of $\Sigma$. Then compose with the projection map $T^2 \to S^1$ to get a map $\Sigma \to S^1$. This is clearly nontrivial on $\pi_1$. Consider then the composition $\Sigma \to S^1 \to M$, which is our desired non-nullhomotopic map, as it is nonzero on $\pi_1$. 
(Note that the technique doesn't work if $\Sigma$ doesn't have a torus in the connected sum decomposition, i.e., if $\Sigma \cong S^2$. In that case, indeed, $\pi_1 \neq 0$ is not sufficient for there to exit a non-null map from $S^2$: take, e.g., $M = S^1$. For nonorientable $\Sigma$, same argument applies by finding a Klein bottle component in $\Sigma$ instead of a torus, again with the exception of $\Bbb{RP}^2$ - if there was a homotopically nontrivial map $\Bbb{RP}^2 \to S^1$, there would have been a nontrivial homomorphism $\Bbb Z/2 \to \Bbb Z$ at the level of fundamental groups, which is nonsense) 
If $\pi_1(M) = 0$ but $\pi_2(M) \neq 0$, consider a representative of some nonzero homotopy class $[f]$ in $\pi_2(M)$, which gives you a non-nullhomotopic map $f : S^2 \to M$. Moreover, since $\pi_1(M) = 0$, under the Hurewicz isomorphism $\pi_2(M) \to H_2(M)$, $[f]$ is sent to a nontrivial homology class $[f^*(S^2)]$ in $M$, hence $f$ is nontrivial in homology. If $\Sigma$ is some higher genus surface, let $\Sigma \to S^2$ be the degree $1$ map given by pinching a complement of a small ball inside a chart in $\Sigma$. The composition $\Sigma \to S^2 \to M$ is non-nullhomotopic, because it's nonzero in $H_2$ (as so are the two maps in the composition). If $\Sigma$ is nonorientable, exact same argument works, except you have to work in homology mod 2. 
