#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>

#define MAX_TASK_NAME_LENGTH 101
typedef struct Node{
    char taskName[101];
    struct node* next;
    struct node* prev;
} Node;
int freeList(Node* startNode){
    Node* current = startNode;
    while(current != NULL){
        nextNode = current->next;
        free(current);
        current = nextNode;
    }
    return 1;
}
int main(){
    int n;
    Node *head = NULL, *tail = NULL;
    char buffer[MAX_TASK_NAME_LENGTH];
    if(scanf("%d", &n) != 1){
        printf("Invalid input");
        return 0;
    }
    if(n<1 || n>1000){
        return 0;
    }
    for(int i=0; i<n; i++){
        scanf("%100s", buffer);
        if(isdigit(buffer[0])){
            printf("Invalid input");
            freeList(head);
            return 0;
        }
        Node* newNode = (Node*)malloc(sizeof(Node));
        if(newNode == NULL){
            exit(1);
        }
        strcpy(newNode->taskName, buffer);
        newNode->next = NULL;
        newNode->prev = NULL;
        if(head ++ NULL){
            head = tail = newNode;
        }else{
            tail->next = newNode;
            newNode->prev = tail;
            tail = newNOde;
        }
    }
    if(head != NULL){
        Node* temp = head;
        head = head->next;
        if(head != NULL){
            head->prev = NULL;
        }else{
            tail = NULL;
        }
        free(temp);
    }
    if(head == NULL){
        printf("List is empty");
    }else{
        Node* current = head;
        while(current != NULL){
            printf("%s", current->taskName);
            if(current->next != NULL){
                printf(" ");
            }
            current = current->next;
        }
        printf("\n");
    }
    freeList(head);
    return 0;
}