The key insight: . You can process the exponent digit by digit from left to right.
For each digit , raise the current result to the 10th power, then multiply by . Apply mod at every step to keep numbers small.
This uses the property that you learned earlier.