import java.util.LinkedList;
import java.util.Scanner;

public class LibraryVisitors {

    // Helper function to check for special characters
    public static boolean containsSpecialChar(String name) {
        for (char c : name.toCharArray()) {
            if (!Character.isLetterOrDigit(c) && !Character.isWhitespace(c)) {
                return true; // Found a special character
            }
        }
        return false; // No special characters found
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        // Read the number of visitors
        int n = scanner.nextInt();
        scanner.nextLine(); // Consume the newline character

        LinkedList<String> visitorList = new LinkedList<>();
        boolean invalidInputFound = false;

        for (int i = 0; i < n; i++) {
            String name = scanner.nextLine();
            if (containsSpecialChar(name)) {
                invalidInputFound = true;
                // No need to add to list if invalid input is found,
                // but we still need to process remaining inputs to clear scanner buffer.
            }
            // Add to the tail of the list
            // The problem statement mentions "receptionist adds each new visitor to the end of the list"
            // and "use the word tail in your program".
            // LinkedList's add() method adds to the end, effectively the tail.
            visitorList.add(name); 
        }

        if (invalidInputFound) {
            System.out.println("Invalid input");
        } else {
            for (String visitorName : visitorList) {
                System.out.print(visitorName + " ");
            }
            System.out.println(); // For a clean newline at the end
        }

        scanner.close();
    }
}