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:- https://www.hackerearth.com/problem/algorithm/area51/
My Soln Link:- https://www.hackerearth.com/submission/14736228/