/**
 * This function takes a list of countries as input and returns a new list
 * containing the countries that have a state with the specified name.
 *
 * @param countries A list of countries and their states
 * @param state The name of the state to search
 * @return A list of countries containing the specified state
 */
fun listCountriesContainingState(countries: List<Pair<String, List<String>>>, state: String): List<String> {

    val countriesWithState = mutableListOf<String>()

    for ((country, states) in countries) {
        for (countryState in states) {
            if (state in countryState) {
                countriesWithState.add(country)
                break
            }
        }
    }

    return countriesWithState
}

// Code to test the function
val countriesData = listOf(
    "Australia" to listOf("New South Wales", "Queensland", "Victoria"),
    "Canada" to listOf("Ontario", "Quebec", "British Columbia"),
    "China" to listOf("Guangdong", "Shandong", "Hunan"),
    "United States" to listOf("California", "Texas", "Florida"),
    "Russia" to listOf("Moscow", "Saint Petersburg", "Novosibirsk"),
    "Brazil" to listOf("Sao Paulo", "Rio de Janeiro", "Bahia")
)
/**
 * This function takes a list of countries as input and returns a new list
 * containing the countries that have a state with the specified name.
 *
 * @param countries A list of countries and their states
 * @param state The name of the state to search
 * @return A list of countries containing the specified state
 */
fun listCountriesContainingState(countries: List<Pair<String, List<String>>>, state: String): List<String> {
/**
 * This function takes a list of countries as input and returns a new list
 * containing the countries that have a state with the specified name.
 *
 * @param countries A list of countries and their states
 * @param state The name of the state to search
 * @return A list of countries containing the specified state
 */
fun listCountriesContainingState(countries: List<Pair<String, List<String>>>, state: String): List<String> {

    val countriesWithState = mutableListOf<String>()

    for ((country, states) in countries) {
        for (countryState in states) {
            if (state in countryState) {
                countriesWithState.add(country)
                break
            }
        }
    }

    return countriesWithState
}

// Code to test the function
val countriesData = listOf(
    "Australia" to listOf("New South Wales", "Queensland", "Victoria"),
    "Canada" to listOf("Ontario", "Quebec", "British Columbia"),
    "China" to listOf("Guangdong", "Shandong", "Hunan"),
    "United States" to listOf("California", "Texas", "Florida"),
    "Russia" to listOf("Moscow", "Saint Petersburg", "Novosibirsk"),
    "Brazil" to listOf("Sao Paulo", "Rio de Janeiro", "Bahia")
)