public static ArrayList<Character[]> solveSubNQ(int k, int n) {
		ArrayList<Character[]> boards = new ArrayList<Character[]>();
		if (k == 1) {
			// there are n ways to put Q on the first row
			for (int i = 0; i < n; i++) {
				Character[] board = new Character[n];
				Arrays.fill(board, '.');
				board[i] = 'Q';
				boards.add(board);
			}
			return boards;
		} else {
			// place the k'th row after the previous row
			ArrayList<Character[]> subBoards = solveSubNQ(k - 1, n);
			int start = (k - 1) * n;
			int end = k * n;
			// to place Q
			for (Character[] board : subBoards) {
				for (int i = start; i < end; i++) {
					if (notConfilict(i, board, n)) {
						Character[] nboard = (Character[]) Arrays.copyOf(board,
								end);
						for (int j = start; j < end; j++) {
							nboard[j] = '.';
						}
						nboard[i] = 'Q';
						boards.add(nboard);
					}
				}
			}
			return boards;
		}
	}