/**
 * Given two lists of firefighter tuples, find the intersection of the two lists based on their indices.
 * Each firefighter tuple contains the firefighter's name as the first element and their availability as a second element.
 * Return a list of firefighter names who are available in both lists.
 *
 * @param firefighters1 List of firefighter tuples (name, availability) for the first group
 * @param firefighters2 List of firefighter tuples (name, availability) for the second group
 * @return List of firefighter names who are available in both groups
 */
fun findMatchingFirefighters(firefighters1: List<Pair<String, Boolean>>, firefighters2: List<Pair<String, Boolean>>): List<String> {

    val commonFirefighters = mutableListOf<String>()

    for (firefighter1 in firefighters1) {
        for (firefighter2 in firefighters2) {
            if (firefighter1.second && firefighter2.second && firefighter1.first == firefighter2.first) {
                commonFirefighters.add(firefighter1.first)
            }
        }
    }

    return commonFirefighters
}

// Example usage
val firefightersGroup1 = listOf(Pair("John", true), Pair("Emily", false), Pair("Michael", true))
val firefightersGroup2 = listOf(Pair("Mary", true), Pair("John", true))
/**
 * Given two lists of firefighter tuples, find the intersection of the two lists based on their indices.
 * Each firefighter tuple contains the firefighter's name as the first element and their availability as a second element.
 * Return a list of firefighter names who are available in both lists.
 *
 * @param firefighters1 List of firefighter tuples (name, availability) for the first group
 * @param firefighters2 List of firefighter tuples (name, availability) for the second group
 * @return List of firefighter names who are available in both groups
 */
fun findMatchingFirefighters(firefighters1: List<Pair<String, Boolean>>, firefighters2: List<Pair<String, Boolean>>): List<String> {
/**
 * Given two lists of firefighter tuples, find the intersection of the two lists based on their indices.
 * Each firefighter tuple contains the firefighter's name as the first element and their availability as a second element.
 * Return a list of firefighter names who are available in both lists.
 *
 * @param firefighters1 List of firefighter tuples (name, availability) for the first group
 * @param firefighters2 List of firefighter tuples (name, availability) for the second group
 * @return List of firefighter names who are available in both groups
 */
fun findMatchingFirefighters(firefighters1: List<Pair<String, Boolean>>, firefighters2: List<Pair<String, Boolean>>): List<String> {

    val commonFirefighters = mutableListOf<String>()

    for (firefighter1 in firefighters1) {
        for (firefighter2 in firefighters2) {
            if (firefighter1.second && firefighter2.second && firefighter1.first == firefighter2.first) {
                commonFirefighters.add(firefighter1.first)
            }
        }
    }

    return commonFirefighters
}

// Example usage
val firefightersGroup1 = listOf(Pair("John", true), Pair("Emily", false), Pair("Michael", true))
val firefightersGroup2 = listOf(Pair("Mary", true), Pair("John", true))