/**
 * This function finds the common elements between two nested lists using nested while loops and the index() method.
 *
 * @param listA A nested list containing elements.
 * @param listB Another nested list containing elements.
 * @return A list containing the common elements between listA and listB.
 */
fun findCommonElements(listA: List<List<Any>>, listB: List<List<Any>>): List<Any> {

    val commonElements = mutableListOf<Any>()

    var outer = 0
    while (outer < listA.size) {
        var inner = 0
        while (inner < listA[outer].size) {
            val element = listA[outer][inner]

            if (listB.any { it.contains(element) }) {
                if (listB.any { it.contains(element) }) {
                    commonElements.add(element)
                }
            }

            inner++
        }
        outer++
    }

    return commonElements
}
/**
 * This function finds the common elements between two nested lists using nested while loops and the index() method.
 *
 * @param listA A nested list containing elements.
 * @param listB Another nested list containing elements.
 * @return A list containing the common elements between listA and listB.
 */
fun findCommonElements(listA: List<List<Any>>, listB: List<List<Any>>): List<Any> {
/**
 * This function finds the common elements between two nested lists using nested while loops and the index() method.
 *
 * @param listA A nested list containing elements.
 * @param listB Another nested list containing elements.
 * @return A list containing the common elements between listA and listB.
 */
fun findCommonElements(listA: List<List<Any>>, listB: List<List<Any>>): List<Any> {

    val commonElements = mutableListOf<Any>()

    var outer = 0
    while (outer < listA.size) {
        var inner = 0
        while (inner < listA[outer].size) {
            val element = listA[outer][inner]

            if (listB.any { it.contains(element) }) {
                if (listB.any { it.contains(element) }) {
                    commonElements.add(element)
                }
            }

            inner++
        }
        outer++
    }

    return commonElements
}