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