regarding O(t*n) soln of Area51 problem on hackerearth

Guys please explain that how could t*n soln can pass where the constraints of n is <=10^9 and t<=50 and secondly how is it possible to calculate factorial of such a huge number like 10^9. This is practically not possible. Please help!
Que Link:-
My Soln Link:-