/**
 * Given a nested list and a list of indices, this function returns the element 
 * at the specified location in the nested list.
 *
 * @param nestedList The nested list to access elements from
 * @param indices The list of indices specifying the location of the element
 * @return The element at the specified location in the nested list
 *
 * Example:
 * val nestedList = listOf(listOf(1, 2, listOf(3, 4)), listOf(5, listOf(6, listOf(7, 8))))
 * val indices = listOf(1, 1, 1)
 * accessNestedElements(nestedList, indices)
 *
 * Output:
 * 8
 */
fun accessNestedElements(nestedList: List<Any>, indices: List<Int>): Any {

    var result = nestedList
    for (idx in indices) {
        result = result[idx] as List<Any>
    }
    return result
}
/**
 * Given a nested list and a list of indices, this function returns the element 
 * at the specified location in the nested list.
 *
 * @param nestedList The nested list to access elements from
 * @param indices The list of indices specifying the location of the element
 * @return The element at the specified location in the nested list
 *
 * Example:
 * val nestedList = listOf(listOf(1, 2, listOf(3, 4)), listOf(5, listOf(6, listOf(7, 8))))
 * val indices = listOf(1, 1, 1)
 * accessNestedElements(nestedList, indices)
 *
 * Output:
 * 8
 */
fun accessNestedElements(nestedList: List<Any>, indices: List<Int>): Any {
/**
 * Given a nested list and a list of indices, this function returns the element 
 * at the specified location in the nested list.
 *
 * @param nestedList The nested list to access elements from
 * @param indices The list of indices specifying the location of the element
 * @return The element at the specified location in the nested list
 *
 * Example:
 * val nestedList = listOf(listOf(1, 2, listOf(3, 4)), listOf(5, listOf(6, listOf(7, 8))))
 * val indices = listOf(1, 1, 1)
 * accessNestedElements(nestedList, indices)
 *
 * Output:
 * 8
 */
fun accessNestedElements(nestedList: List<Any>, indices: List<Int>): Any {

    var result = nestedList
    for (idx in indices) {
        result = result[idx] as List<Any>
    }
    return result
}