Math day problem doubt

The brute force method is obvious in this problem, but i am not able to drive an efficient method, i can use fast exponentiation for a^n! but what about n!, how can i calculate that efficiently, the value is way too big for 10^5

by breaking down n! in to steps.
use property that you used in class tenth-;
a^(b*c)=(a^b)^c;
use fast exponentiation in every step.

use this property

n^(a*b) = (n^a)^b