For any integer $a$, there exists a postive integer $m$ such $m^m\equiv a\pmod n$ 
Let $n\ge 2$ be  postive integer. The positive integer $n$ is called "good", such that for any integer $a$, there exists a postive integer $m$ such that
  $$m^m\equiv a\pmod n$$
  Show that $n$ is "good" if only if $(n,\varphi(n))=1$, where $\varphi(n)$ is Euler's totient function.

Firstly, I would like to say that this is contest problem, and, secondly, I think this question may use Euler's theorem:

If $m\equiv p\pmod n$,and
  $m\equiv q\pmod{\varphi(n)}$.the we have
  $$m^m\equiv p^q\pmod {\varphi(n)}$$

 A: CASE I  if $\gcd(n,\phi(n))\ne 1$
First suppose there is a prime $p$ such that $p^2$ divides $n$ and suppose that we could solve $m^m\equiv p\pmod n$. Then $m$ would be a multiple of $p$ and so $p^2$ would be a factor of $m^m$ and therefore of $p$, a contradiction.
Otherwise there must be two primes $p$ and $q$ such that $pq$ divides $n$ and $p$ divides $q-1$.
Consider $\{ x^p|(x,q)=1\}$. This set contains $\frac{q-1}{p}$ residues modulo $q$ and so we can choose a positive integer $t$ such that $tp$ is not congruent modulo $q$ to any member of this set. Now suppose that we could solve $m^m\equiv tp\pmod n$. Then $m$ would be a multiple of $p$ and so $tp$ would be congruent modulo $q$ to a $p$th power after all, a contradiction.
CASE II  if $\gcd(n,\phi(n))= 1$
First suppose that $a$ is coprime to $n$. Since $\phi(n)$ is also coprime to $n$ we can choose a positive integer $t$ such that $1+t\phi(n)\equiv a\pmod n$. Let $m=1+t\phi(n)$. Then $$m^m \equiv (1+t\phi(n))(1+t\phi(n))^{t\phi(n)}\equiv 1+t\phi(n)\equiv a\pmod n.$$
Now suppose $a$ is not coprime to $n$. Let $n=PQ$ where $P$ divides $a$ and $Q$ is coprime to $a$ and $P$. 
Then we can find a positive integer $t$ such that  $(tP)^P\equiv a\pmod Q$ and then  find an integer $s$  such that $t\equiv 1+s\phi(Q)\pmod Q$. Let $m=(1+s\phi(Q))P$. Then $$m^m \equiv (tP)^{(1+s\phi(Q))P}\equiv (tP)^P\equiv a\pmod Q.$$
$P$ divides both $m$ and $a$ and so $m^m \equiv a\pmod {PQ}.$
