Remember the modulo property: . This applies to as well.
You compute first (recursively). Then raise that result to the 10th power, modulo 1337. Multiply by , and take modulo again.
Each exponentiation step uses the fast power function. The recursion depth is at most the number of digits in , which keeps the computation manageable.