public static void enumerate_cnt(int[] cnt, int[] q, int n) {
    	int N = q.length;
        if (n == N) {
        	cnt[0]++;
        }
        else {
            for (int i = 0; i < N; i++) {
                q[n] = i;
                if (isValidQ(q, n)) enumerate_cnt(cnt, q, n+1);
            }
        }
    }