/**
 * This function finds the animals that exist in both lists and have the same number of legs.
 *
 * @param animalsList1 List of pairs representing the animals and their corresponding number of legs.
 * @param animalsList2 List of pairs representing the animals and their corresponding number of legs.
 * @return List of pairs containing the matching animals and their number of legs.
 */
fun findMatchingAnimals(animalsList1: List<Pair<String, Int>>, animalsList2: List<Pair<String, Int>>): List<Pair<String, Int>> {

    val matchingAnimals = mutableListOf<Pair<String, Int>>()

    for (animal1 in animalsList1) {
        for (animal2 in animalsList2) {
            if (animal1.first == animal2.first && animal1.second == animal2.second) {
                matchingAnimals.add(animal1)
            }
        }
    }

    return matchingAnimals
}
/**
 * This function finds the animals that exist in both lists and have the same number of legs.
 *
 * @param animalsList1 List of pairs representing the animals and their corresponding number of legs.
 * @param animalsList2 List of pairs representing the animals and their corresponding number of legs.
 * @return List of pairs containing the matching animals and their number of legs.
 */
fun findMatchingAnimals(animalsList1: List<Pair<String, Int>>, animalsList2: List<Pair<String, Int>>): List<Pair<String, Int>> {
/**
 * This function finds the animals that exist in both lists and have the same number of legs.
 *
 * @param animalsList1 List of pairs representing the animals and their corresponding number of legs.
 * @param animalsList2 List of pairs representing the animals and their corresponding number of legs.
 * @return List of pairs containing the matching animals and their number of legs.
 */
fun findMatchingAnimals(animalsList1: List<Pair<String, Int>>, animalsList2: List<Pair<String, Int>>): List<Pair<String, Int>> {

    val matchingAnimals = mutableListOf<Pair<String, Int>>()

    for (animal1 in animalsList1) {
        for (animal2 in animalsList2) {
            if (animal1.first == animal2.first && animal1.second == animal2.second) {
                matchingAnimals.add(animal1)
            }
        }
    }

    return matchingAnimals
}