/**
 * Given a list of musicians, find the common instruments they all play.
 *
 * @param musicians A list of lists representing musicians and their instruments.
 * @return A list of common instruments played by all musicians.
 */
fun findCommonInstruments(musicians: List<List<String>>): List<String> {

    // Initialize a set with the instruments played by the first musician
    var commonInstruments = musicians[0].toSet()

    // Iterate over the remaining musicians
    for (musician in musicians.subList(1, musicians.size)) {
        // Convert the list of instruments to a set for easier comparison
        val instruments = musician.toSet()

        // Intersect the sets of instruments to find the common ones
        commonInstruments = commonInstruments.intersect(instruments)
    }

    // Convert the set of common instruments back to a list
    return commonInstruments.toList()
}
/**
 * Given a list of musicians, find the common instruments they all play.
 *
 * @param musicians A list of lists representing musicians and their instruments.
 * @return A list of common instruments played by all musicians.
 */
fun findCommonInstruments(musicians: List<List<String>>): List<String> {
/**
 * Given a list of musicians, find the common instruments they all play.
 *
 * @param musicians A list of lists representing musicians and their instruments.
 * @return A list of common instruments played by all musicians.
 */
fun findCommonInstruments(musicians: List<List<String>>): List<String> {

    // Initialize a set with the instruments played by the first musician
    var commonInstruments = musicians[0].toSet()

    // Iterate over the remaining musicians
    for (musician in musicians.subList(1, musicians.size)) {
        // Convert the list of instruments to a set for easier comparison
        val instruments = musician.toSet()

        // Intersect the sets of instruments to find the common ones
        commonInstruments = commonInstruments.intersect(instruments)
    }

    // Convert the set of common instruments back to a list
    return commonInstruments.toList()
}