public static void enumerate(List<String[]> ret, int[] q, int n) {
    	int N = q.length;
        if (n == N) {
        	String[] temp = new String[N];
        	
        	for (int j = 0; j < N; ++j) {
        		temp[j] = "";
        		for (int i = 0; i < N; ++i) {
        			if (q[i] == j) temp[j] += "Q";
        			else temp[j] += ".";
        		}
            	System.out.println(temp[j]);
        	}
        	ret.add(temp);
        }
        else {
            for (int i = 0; i < N; i++) {
                q[n] = i;
                if (isValidQ(q, n)) enumerate(ret, q, n+1);
            }
        }
    }