/**
 * This function takes a nested map containing negative integers
 * and returns a list of all the negative elements in the map.
 *
 * @param matrix A nested map containing negative integers.
 * @return A list of all the negative integers in the map.
 */
fun findNegativeElements(matrix: Map<String, Any>): List<Int> {

    val negativeElements = mutableListOf<Int>()

    for ((key, value) in matrix) {
        when (value) {
            is Map<*, *> -> negativeElements.addAll(findNegativeElements(value as Map<String, Any>))
            is List<*> -> {
                for (element in value) {
                    if (element is Int && element < 0) {
                        negativeElements.add(element)
                    }
                }
            }
            is Int -> {
                if (value < 0) {
                    negativeElements.add(value)
                }
            }
        }
    }

    return negativeElements
}
/**
 * This function takes a nested map containing negative integers
 * and returns a list of all the negative elements in the map.
 *
 * @param matrix A nested map containing negative integers.
 * @return A list of all the negative integers in the map.
 */
fun findNegativeElements(matrix: Map<String, Any>): List<Int> {
/**
 * This function takes a nested map containing negative integers
 * and returns a list of all the negative elements in the map.
 *
 * @param matrix A nested map containing negative integers.
 * @return A list of all the negative integers in the map.
 */
fun findNegativeElements(matrix: Map<String, Any>): List<Int> {

    val negativeElements = mutableListOf<Int>()

    for ((key, value) in matrix) {
        when (value) {
            is Map<*, *> -> negativeElements.addAll(findNegativeElements(value as Map<String, Any>))
            is List<*> -> {
                for (element in value) {
                    if (element is Int && element < 0) {
                        negativeElements.add(element)
                    }
                }
            }
            is Int -> {
                if (value < 0) {
                    negativeElements.add(value)
                }
            }
        }
    }

    return negativeElements
}