My code is giving run-time error in submit

My code is giving a run-time error in submit, only 1 test case is passing please review my code:- https://ide.codingblocks.com/s/259583

@D19APPND0003
It’s not possible to calculated factorial of large numbers that’s why your code is giving runtime error.
Actually you don’t need of calculated factorial in this question. Simply count number of nodes in different connected component and multiple them to get final ans.

@D19APPND0003
Example: in given sample input i.e.
5 3
0 1
2 3
0 4
There are two connect components i.e {0,1,4} and {2,3} so final ans is 2*3=6

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.