#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct node{
    char str[20];
    struct node *next;
}Node;

Node *top = NULL;

void push(char *str){
    Node *newnode = (Node*)malloc(sizeof(Node));
    
    strcpy(newnode->str, str);
    newnode->next = top;
    top = newnode;
}

void popAll(){
    while(top!=NULL){
        printf("%s ", top->str);
        Node *temp = top;
        topr = top->next;
        free(temp);
    }
}
int main(){
    int n;
    scanf("%d", &n);
    if(n<0){
        prinntf("Invalid input");
        return 0;
    }
    
    char sentence[10];
    getchar();
    fgets(sentence, sizeof(sentence), stdin);
    
    char *str = strtok(sentence, "\n");
    int coount = 0;
    while(str != NULL && count < n){
        push(str);
        str = strtok(NULL, "\n");
        count++;
    }
    popAll();
    return 0;
}