/**
 * Given a set of dancers and a list of pairs, find the dancers that are common to all the pairs.
 *
 * @param dancers A set of Dancer objects.
 * @param pairs A list of pairs, where each pair is a set containing two Dancer objects.
 * @return A set of Dancer objects that are common to all the pairs.
 *
 * Example:
 * dancers = setOf("Dancer A", "Dancer B", "Dancer C", "Dancer D")
 * pairs = listOf(setOf("Dancer A", "Dancer B"), setOf("Dancer C", "Dancer D"), setOf("Dancer B", "Dancer D"))
 * getCommonDancersInPairs(dancers, pairs) // Output: setOf("Dancer B", "Dancer D")
 */
fun getCommonDancersInPairs(dancers: Set<String>, pairs: List<Set<String>>): Set<String> {

    var commonDancers = dancers.toMutableSet()
    for (pair in pairs) {
        commonDancers.retainAll(pair)
    }
    return commonDancers
}
/**
 * Given a set of dancers and a list of pairs, find the dancers that are common to all the pairs.
 *
 * @param dancers A set of Dancer objects.
 * @param pairs A list of pairs, where each pair is a set containing two Dancer objects.
 * @return A set of Dancer objects that are common to all the pairs.
 *
 * Example:
 * dancers = setOf("Dancer A", "Dancer B", "Dancer C", "Dancer D")
 * pairs = listOf(setOf("Dancer A", "Dancer B"), setOf("Dancer C", "Dancer D"), setOf("Dancer B", "Dancer D"))
 * getCommonDancersInPairs(dancers, pairs) // Output: setOf("Dancer B", "Dancer D")
 */
fun getCommonDancersInPairs(dancers: Set<String>, pairs: List<Set<String>>): Set<String> {
/**
 * Given a set of dancers and a list of pairs, find the dancers that are common to all the pairs.
 *
 * @param dancers A set of Dancer objects.
 * @param pairs A list of pairs, where each pair is a set containing two Dancer objects.
 * @return A set of Dancer objects that are common to all the pairs.
 *
 * Example:
 * dancers = setOf("Dancer A", "Dancer B", "Dancer C", "Dancer D")
 * pairs = listOf(setOf("Dancer A", "Dancer B"), setOf("Dancer C", "Dancer D"), setOf("Dancer B", "Dancer D"))
 * getCommonDancersInPairs(dancers, pairs) // Output: setOf("Dancer B", "Dancer D")
 */
fun getCommonDancersInPairs(dancers: Set<String>, pairs: List<Set<String>>): Set<String> {

    var commonDancers = dancers.toMutableSet()
    for (pair in pairs) {
        commonDancers.retainAll(pair)
    }
    return commonDancers
}