import re

class Node:
    def _init_(self, data):
        self.data = data
        self.next = None

class VisitorList:
    def _init_(self):
        self.head = None
        self.tail = None  # Use the tail pointer

    def add_visitor(self, name):
        new_node = Node(name)
        if self.head is None:
            self.head = self.tail = new_node
        else:
            self.tail.next = new_node
            self.tail = new_node

    def is_valid(self, name):
        # Only allow alphabetic names (no special characters)
        return re.match("^[A-Za-z]+$", name) is not None

    def print_visitors(self):
        current = self.head
        output = []
        while current is not None:
            output.append(current.data)
            current = current.next
        print(" ".join(output))

def main():
    n = int(input())
    visitors = VisitorList()
    invalid = False

    for _ in range(n):
        name = input().strip()
        if not visitors.is_valid(name):
            invalid = True
        visitors.add_visitor(name)
    
    if invalid:
        print("Invalid input")
    else:
        visitors.print_visitors()

if _name_ == "_main_":
    main()