/**
 * This function takes in two lists and returns the intersection of elements
 * that are common between them. It modifies the elements of the second list
 * using nested loops with sets.
 */
fun intersectionLists(list1: List<Any>, list2: MutableList<Any>): Set<Any> {

    // Set to store the common elements
    val commonElements = mutableSetOf<Any>()

    // Iterate through each element in the first list
    for (element in list1) {
        // Iterate through each element in the second list
        val iterator = list2.iterator()
        while (iterator.hasNext()) {
            val nestedElement = iterator.next()
            // Check if the elements are equal
            if (element == nestedElement) {
                // Modify the element in the second list
                iterator.remove()
                // Add the common element to the set
                commonElements.add(element)
            }
        }
    }

    // Return the set of common elements
    return commonElements
}
/**
 * This function takes in two lists and returns the intersection of elements
 * that are common between them. It modifies the elements of the second list
 * using nested loops with sets.
 */
fun intersectionLists(list1: List<Any>, list2: MutableList<Any>): Set<Any> {
/**
 * This function takes in two lists and returns the intersection of elements
 * that are common between them. It modifies the elements of the second list
 * using nested loops with sets.
 */
fun intersectionLists(list1: List<Any>, list2: MutableList<Any>): Set<Any> {

    // Set to store the common elements
    val commonElements = mutableSetOf<Any>()

    // Iterate through each element in the first list
    for (element in list1) {
        // Iterate through each element in the second list
        val iterator = list2.iterator()
        while (iterator.hasNext()) {
            val nestedElement = iterator.next()
            // Check if the elements are equal
            if (element == nestedElement) {
                // Modify the element in the second list
                iterator.remove()
                // Add the common element to the set
                commonElements.add(element)
            }
        }
    }

    // Return the set of common elements
    return commonElements
}