This problem is originally from PuMAC$^{a}$ $2007$. I tried using modular arithmetic (Euler's totient function$(\phi)$) but could not solve more than this:
I calculated Euler's totient functions separately by the formula $\phi(n)=n\big(1-\frac{1}{p_1}\big)\big(1-\frac{1}{p_2}\big)\cdots\big(1-\frac{1}{p_k}\big),$ and then I worked them with $\pmod{1000}.$ But it looks very tedious!
I used the property that when $a$ and $n$ are relatively prime we have
$a^b\equiv a^{b\mod{\phi(n)}}$ $\mod{n}$
It then suffices to calculate $b\mod{\phi(n)}$.
After this I have not been able to proceed further so I am hoping for someone's help at the moment. Any guidance would be highly appreciated. Thank you!