public static boolean solve_Sudoku_helper(int[][] A, int i, int j) {
		if (i == A.length) {
			i = 0; // starts a new row.
			if (++j == A[i].length) {
				return true; // Entire matrix has been filled without conflict.
			}
		}

		// Skips nonempty entries.
		if (A[i][j] != 0) {
			return solve_Sudoku_helper(A, i + 1, j);
		}

		for (int val = 1; val <= A.length; ++val) {
		    // Note: practically, it's substantially quicker to check if entry val
		    // conflicts with any of the constraints if we add it at (i,j) before
		    // adding it, rather than adding it and then calling is_valid_Sudoku.
		    // The reason is that we know we are starting with a valid configuration,
		    // and the only entry which can cause a problem is entryval at (i,j).
			if (valid_to_add(A, i, j, val)) {
				A[i][j] = val;
				if (solve_Sudoku_helper(A, i + 1, j)) {
					return true;
				}
			}
		}

		A[i][j] = 0; // undos assignment.
		return false;
	}