""" name: Nicholas Tamassia Honor Code and Acknowledgments: This work complies with the JMU Honor Code. Comments here on your code and submission. """ import sys # All modules for CS 412 must include a main method that allows it # to imported and invoked from other python scripts def main(): sounds: list[str] = sys.stdin.readline().strip().split(" ") num_animals: int = int(sys.stdin.readline().strip()) animal_map: dict[str, str] = {} for line in sys.stdin.readlines()[:num_animals]: animal, sound = line.strip().split(" goes ") if sound not in animal_map: animal_map[sound] = animal fox_sounds: list[str] = [] animals_ecountered: set[str] = set() for sound in sounds: if sound in animal_map: animal = animal_map[sound] if animal not in animals_ecountered: animals_ecountered.add(animal) else: fox_sounds.append(sound) print(f"what the fox says: {' '.join(fox_sounds)}") print(f"also heard: {' '.join(animals_ecountered)}") if __name__ == "__main__": main()