/**
 * Given a sequence of lists, find the common elements among all the lists using nested loops.
 *
 * @param sequence A sequence of lists
 * @return A list containing the common elements present in all the lists
 */
fun intersectionOfNestedLoops(sequence: List<List<Any>>): List<Any> {

    // Initialize the common elements as the elements of the first list
    var commonElements = sequence[0]

    // Iterate over each list in the sequence
    for (lst in sequence.subList(1, sequence.size)) {
        // Create an empty list to store the common elements between two lists
        val commonElementsTemp = mutableListOf<Any>()

        // Iterate over each element in the current list
        for (element in lst) {
            // Check if the element is present in the common elements list
            if (element in commonElements) {
                // If present, add it to the temporary common elements list
                commonElementsTemp.add(element)
            }
        }

        // Update the common elements list with the temporary common elements list
        commonElements = commonElementsTemp
    }

    return commonElements
}
/**
 * Given a sequence of lists, find the common elements among all the lists using nested loops.
 *
 * @param sequence A sequence of lists
 * @return A list containing the common elements present in all the lists
 */
fun intersectionOfNestedLoops(sequence: List<List<Any>>): List<Any> {
/**
 * Given a sequence of lists, find the common elements among all the lists using nested loops.
 *
 * @param sequence A sequence of lists
 * @return A list containing the common elements present in all the lists
 */
fun intersectionOfNestedLoops(sequence: List<List<Any>>): List<Any> {

    // Initialize the common elements as the elements of the first list
    var commonElements = sequence[0]

    // Iterate over each list in the sequence
    for (lst in sequence.subList(1, sequence.size)) {
        // Create an empty list to store the common elements between two lists
        val commonElementsTemp = mutableListOf<Any>()

        // Iterate over each element in the current list
        for (element in lst) {
            // Check if the element is present in the common elements list
            if (element in commonElements) {
                // If present, add it to the temporary common elements list
                commonElementsTemp.add(element)
            }
        }

        // Update the common elements list with the temporary common elements list
        commonElements = commonElementsTemp
    }

    return commonElements
}