/**
 * Given two dictionaries containing lists as values, 
 * the function should find the common elements 
 * between the lists and return a list of these common elements.
 *
 * @param dic1 The first dictionary.
 * @param dic2 The second dictionary.
 * @return A list of common elements between the lists.
 *
 * Example:
 * val dic1 = mapOf('A' to listOf('X', 'Y', 'Z'), 'B' to listOf('Y', 'Z', 'W'))
 * val dic2 = mapOf('C' to listOf('Z', 'W', 'X'), 'D' to listOf('U', 'V', 'Z'))
 * findCommonElements(dic1, dic2) -> ['Z']
 */
fun findCommonElements(dic1: Map<String, List<String>>, dic2: Map<String, List<String>>): List<String> {

    val commonElements = mutableListOf<String>()
    for ((_, value1) in dic1) {
        for ((_, value2) in dic2) {
            commonElements.addAll((value1 intersect value2).toList())
        }
    }
    return commonElements.toSet().toList()
}
/**
 * Given two dictionaries containing lists as values, 
 * the function should find the common elements 
 * between the lists and return a list of these common elements.
 *
 * @param dic1 The first dictionary.
 * @param dic2 The second dictionary.
 * @return A list of common elements between the lists.
 *
 * Example:
 * val dic1 = mapOf('A' to listOf('X', 'Y', 'Z'), 'B' to listOf('Y', 'Z', 'W'))
 * val dic2 = mapOf('C' to listOf('Z', 'W', 'X'), 'D' to listOf('U', 'V', 'Z'))
 * findCommonElements(dic1, dic2) -> ['Z']
 */
fun findCommonElements(dic1: Map<String, List<String>>, dic2: Map<String, List<String>>): List<String> {
/**
 * Given two dictionaries containing lists as values, 
 * the function should find the common elements 
 * between the lists and return a list of these common elements.
 *
 * @param dic1 The first dictionary.
 * @param dic2 The second dictionary.
 * @return A list of common elements between the lists.
 *
 * Example:
 * val dic1 = mapOf('A' to listOf('X', 'Y', 'Z'), 'B' to listOf('Y', 'Z', 'W'))
 * val dic2 = mapOf('C' to listOf('Z', 'W', 'X'), 'D' to listOf('U', 'V', 'Z'))
 * findCommonElements(dic1, dic2) -> ['Z']
 */
fun findCommonElements(dic1: Map<String, List<String>>, dic2: Map<String, List<String>>): List<String> {

    val commonElements = mutableListOf<String>()
    for ((_, value1) in dic1) {
        for ((_, value2) in dic2) {
            commonElements.addAll((value1 intersect value2).toList())
        }
    }
    return commonElements.toSet().toList()
}