NZEC error in java

import java.io.BufferedReader;
import java.io.InputStreamReader;

class Fombinatorial {
static String line;
static int T, i, j, temp1, temp2, temp3;
static int Q[] = new int[1000];
static int r[][] = new int[1000][10000];
static int n[] = new int[1000];
static int m[] = new int[1000];
static int ansWer[][] = new int[1000][10000];

public static void main(String[] args) throws Exception {
	// TODO Auto-generated method stub
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	line = br.readLine();
	T = Integer.parseInt(line);
	String inpNMQ[] = new String[10];
	for (i = 0; i < T; i++) {
		inpNMQ = br.readLine().split(" ");
		n[i] = Integer.parseInt(inpNMQ[0]);
		m[i] = Integer.parseInt(inpNMQ[1]);
		Q[i] = Integer.parseInt(inpNMQ[2]);
		for (j = 0; j < Q[i]; j++) {
			line = br.readLine();
			r[i][j] = Integer.parseInt(line);
		}
	}
	for (i = 0; i < T; i++) {
		for (j = 0; j < Q[i]; j++) {
			temp1 = fombNat(n[i]);
			temp2 = fombNat(r[i][j]);
			temp3 = fombNat(n[i] - r[i][j]);
			temp2 = temp2 * temp3;
			ansWer[i][j] = temp1 / temp2;
			ansWer[i][j] = ansWer[i][j] % m[i];
			System.out.println(ansWer[i][j]);
		}
	}

}

public static int fombNat(int n) {
	int i, res = 1;
	for (i = 1; i <= n; i++)
		res *= Math.pow(i, i);
	return res;
}

}
input:
1
5 24 2
2
3

//yet i am getting NZEC error while IDE provided by codechef does not give any error