#!/bin/python import sys mymod = 663224321 from math import sqrt rfccache = {0:1, 1:1, 2:2} def rfc(n): if n not in rfccache: if int(n/(1 + (1.0 / sqrt(n)))) not in rfccache: rfccache[int(n/(1 + (1.0 / sqrt(n))))] = rfc(int(n/(1 + (1.0 / sqrt(n))))-1) * int(n/(1 + (1.0 / sqrt(n)))) rfccache[n] = rfc(n-1) * n return rfccache[n] binocache = {} def bino(x,y): if (x, y) not in binocache: if x < y: binocache[(x,y)] = 0 return binocache[(x,y)] binocache[(x,y)] = rfc(x) / ((rfc(y)*rfc(x-y))) return binocache[(x, y)] return binocache[(x,y)] answercache = {} def answer(N, K): if K < N - 1 or K > (N * (N - 1)) / 2: return 0 if (N, K) not in answercache: temp4 = bino(N,2) if K == N - 1: answercache[(N,K)] = N**(N-2) return answercache[(N,K)] if K == (N * (N - 1)) / 2: return 1 result = bino((temp4),K) if K < bino(N-1,2) + 1: for i in xrange(1,N): temp1 = bino(N-1,i-1) temp2 = bino(N-i,2) temp3 = bino(i,2) for j in xrange(i-1, min(temp3,K) + 1): result -= temp1 * bino(temp2,K-j) * answer(i, j) answercache[(N,K)] = int(result) return answercache[(N,K)] return bino(temp4,K) return answercache[(N, K)] q = int(raw_input().strip()) for a0 in xrange(q): n = int(raw_input().strip()) res = 0 for i in xrange(n-1,(n*(n-1))/2): res += answer(n,i) if res == mymod - 1: print 0 else: print (res % mymod) + 1