Learning Hierarchical Polynomials with Three-Layer Neural Networks