Whats wrong in code due to which test cases are failing

@anuranjan8319918906,
Why are you finding inverse like that, you can simply use this:
a^{-1}%p = a^{p-2}%p

According to me I did that only using fast modulo exponentiation…

@anuranjan8319918906,
(m!)^{-1} % p != (m!%p)^{-1}%p

please give solution of this problem…

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.