import java.util.Scanner;
import java.util.regex.Pattern;

public class Main {

    // Node class for the linked list
    static class Node {
        String data;
        Node next;

        Node(String data) {
            this.data = data;
            this.next = null;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        sc.nextLine(); // Consume the newline character

        Node head = null;
        Node tail = null; // Pointer to the end of the list

        // Regex to find any character that is not a letter or a digit
        Pattern specialCharPattern = Pattern.compile("[^a-zA-Z0-9]");

        for (int i = 0; i < n; i++) {
            String visitorName = sc.nextLine();

            // Check if the name contains any special characters
            if (specialCharPattern.matcher(visitorName).find()) {
                System.out.println("Invalid input");
                sc.close();
                return; // Exit if an invalid name is found
            }

            // Create a new node for the valid visitor
            Node newNode = new Node(visitorName);

            // Add the new visitor to the end of the list
            if (head == null) {
                // If the list is empty, the new node is both head and tail
                head = newNode;
                tail = newNode;
            } else {
                // Otherwise, add the new node after the current tail
                tail.next = newNode;
                tail = newNode; // Update the tail to be the new node
            }
        }

        // Print the names in the order they were added
        StringBuilder output = new StringBuilder();
        Node current = head;
        while (current != null) {
            output.append(current.data);
            if (current.next != null) {
                output.append(" ");
            }
            current = current.next;
        }

        System.out.println(output.toString());
        sc.close();
    }
}