I am implementing a cryptographic accumulator and I need to obtain the value a ^ b ^ c ^ d ^ e mod f where a b c d and e are very large numbers. It is written A^bcde mod f with the bcde above the A as in normal exponentiation. I am not sure how to do this with multiple exponents and I can not find much to clarify it for me. I imagine it must not be asking me for a ** b ** c ** d ** e mod f because that would never finish computing due to the very large (over 1000 bits each) size of the variables. I have access to a method that does modular exponentiation but it only allows one exponent. The only way I can imagine it making sense is if it is asking for ((((a ** b) mod f) ** c) mod f) etc because any other way seems like it would take too much processing time and memory. Can anyone clear up for me what exactly I am suppoused to do, and maybe point me in the right direction?

disclaimer: I know I should not rely on my own cryptography especially if I don't know how to do multi exponent modular exponentiation, however I do not plan to rely on what I am implementing until and unless people who know more about crypto than I do look over it and tell me I did a good enough job , and I am mostly just doing this fun.