I am solving this problem but I don’t understand why this this solution is Accepted and why this it not ? (Well I understand the reason that in the last case at time of taking inverse the modulo number is not prime but why the upper one got accepted as => (a ^ b) % mod = a ^(b % (mod-1)) % mod for large b).

Can someone please help me understanding this.

@taran_1407 @vijju123 can you please look into it.