#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 *str){
    Node *newnode = (Node *)malloc(sizeof(Node));
    strcpy(newnode->word, str);
    newnode->next = top;
    top = newnode;
}

void popAll(){
    while(top!=NULL){
        printf("%s ", top->word);
        Node *temp = top;
        top = top->next;
        free(temp);
    }
    print("\n");
}
int main(){
    int n;
    scanf("%d", &n);
    if(n < 0){
        printf("Invalid input");
        return 0;
    }
    
    char sentence[101];
    while(getchar()!='\n');
    fgets(sentence, sizeof(sentence), stdin);
    
    char *word = strtok(sentence, " \n\t");
    int count = 0;
    while(word!= NULL && count < n){
        push(word);
        word = strtok(NULL, " \n\t");
        count++;
    }
    popAll();
    return 0;
}