python NZEC error

import math;
T=int(raw_input());
a=[];
for i in range(T):
a=raw_input().split();
N=int(a[0]);
M=int(a[1]);
K=int(a[2]);
n=math.factorial(N+M-2)/(math.factorial(N-1)*math.factorial(M-1));

    a=math.factorial(N+M-3)/(math.factorial(N-1)*math.factorial(M-2));
    print n;
    print a;  

Why is this code giving me an NZEC error?

The NZEC error happens because, your pgm terminated with some sort of run-time error. Some reasons, the code can throw NZEC:

  1. Trying to convert something that is not an integer (like, empty or non-empty strings) into an int.
  2. Not enough elements in a and a list-index-out-of-bounds error occurs (possibly at the expression a[2] as the value calculated here doesn’t seem like being used anywhere, and might not be actually present in the input.)
  3. incorrect argument for math.factorial. Check here for details on arguments to the function.

are you sure the values passed to math.factorial are positive. it would be better if you post a link to the question