grop of order p^3 , group homomorphism

Prove that if p is an odd prime and P is a group of order $\displaystyle p^{3} $ then the $\displaystyle p^{th} $ power map $\displaystyle x -> x^{p} $ is a homomorphism of P into Z(P). If P is not cyclic , show that the kernel of the $\displaystyle p^{th} $ map has order $\displaystyle p^{2} $ or $\displaystyle p^{3}$. Is the squaring map a homomorphism in nonabelian groups of order 8? Where the oddness of p needed in the above proof?

Hint: Assume x, y in G and both x and y commute with $\displaystyle [x,y]=x^{-1} y^{-1} xy$. Prove that for all n in Z+ , $\displaystyle (xy)^{n} = x^{n} y^{n} [y,x]^{(n(n-1)/2)} $

My problem is I can't see why the hint holds.I aldo don't understand where we

use the hint in the original problem.Can anybody please help?