How can I compute x^(y^z) mod p in O(log(max{x, y, z, p}) time using Fermat\'s little theorem where x,y,z,p are Natural numbers and p is prime