#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX_WORDS 10
#define MAX_LENGTH 100
int main() {
    int n;
    char sentence[MAX_LENGTH];
    char stack[MAX_WORDS][MAX_LENGTH];
    int top = -1;
    scanf("%d", &n);
    getchar();
    fgets(sentence, sizeof(sentence), stdin);
    if(strlen(sentence) == 0 || sentence[0] == '\n'){
        printf("Invalid input.\n");
        return 0;
    }
    char *word = strtok(sentence, " \n");
    while (word != NULL && top < n - 1) {
        strcpy(stack[++top], word);
        word = strtok(NULL, " \n");
    }
    if(int i = top; i >= 0; i--){
        printf("%s\n", stack[top]);
    }else{
        printf("Invalid input");
    }
    return 0;
    }