grop of order p^3 , group homomorphism

Prove that if p is an odd prime and P is a group of order then the power map is a homomorphism of P into Z(P). If P is not cyclic , show that the kernel of the map has order or . 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 . Prove that for all n in Z+ ,

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?