TITLE: $|G|=p^3$. Prove that $\phi(x)=x^p$ is a homomorphism
QUESTION [8 upvotes]: Let $p$ be an odd prime and $G$ a group of order $p^3$. Prove that the $p$-th power map $x  \mapsto x^p$ is a homomorphism $G \rightarrow G$.

The abelian case is easy. Suppose $G$ is non-abelian group. If $x \in G$  or $y \in G$ has order $p$, then $\phi(xy)=\phi(x)\phi(y)$. Thus, we can assume that $x,y$ are order of $p^2$. 
That's what I did. I don't have any tools. I need your help.

REPLY [8 votes]: Hint: If $G$ is not abelian, $|Z(G)|=p$. Then, notice that $xy=yxh$ for some $h \in Z(G)$. Therefore, you can write $(xy)^p=x^py^p h^q$ for some integer $q$; it turns out that $q$ is divisible by $p$, hence $h^q=1$.