import java.util.Scanner;
public class LibraryVisitors {
    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<>();

        // Regex to check for special characters (anything not alphanumeric or space)
        Pattern p = Pattern.compile("[^a-zA-Z0-9\\s]");

        for (int i = 0; i < n; i++) {
            String visitorName = scanner.nextLine();
            Matcher m = p.matcher(visitorName);

            // If a special character is found, print "Invalid input" and exit
            if (m.find()) {
                System.out.println("Invalid input");
                scanner.close();
                return;
            }
            // Add the valid name to the tail of the list
            visitorList.addLast(visitorName); 
        }

        // Print all valid names separated by spaces
        for (int i = 0; i < visitorList.size(); i++) {
            System.out.print(visitorList.get(i));
            if (i < visitorList.size() - 1) {
                System.out.print(" ");
            }
        }
        System.out.println(); // For a newline at the end

        scanner.close();
    }
}