import re

# Function to check if the name contains only alphabets (no special characters)
def is_valid_name(name):
    return bool(re.match("^[A-Za-z]+$", name))

def main():
    n = int(input().strip())  # Number of visitors
    tail = []  # List to store visitors in order
    
    for _ in range(n):
        name = input().strip()
        if not is_valid_name(name):
            print("Invalid input.")
            return
        tail.append(name)
    
    print(" ".join(tail))

if __name__ == "__main__":
    main()