#include<stdio.h>
#include<string.h>
#include<string.h>

typedef struct node
{
    char word[20];
    struct node *node;
}Node;
Node *top = NULL;
void push(char *str)
{
    Node *newnode = (Node *)malloc(sizeof(Node));
    
    if(newnode == NULL)
    {
    return;
}
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);
    }
    printf("\n");
    }

int main()
{
    int n;
    scanf("%d",&n);
    if(n<0)
    {
        printf("Invalid input");
        return 0;
    }
    char sentence[100];
    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;
}