#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct SN*{
    char ti[101];
    struct SN* p;
    struct SN* n;
};
int f(struct SN* h){
    if(h == NULL){
        return 1;
    }
    struct SN* t = h->p;
    t->n = NULL;
    struct SN* c = h;
    while(c != NULL){
        struct SN* te = c;
        c = c->n;
        free(te);
    }
    return 1;
}
int main(){
    int n, k, i;
    struct SN *h = NULL, *t = NULL;
    char b[101];
    if(scanf("%d", &n) != 1){
        printf("Invalid input");
        return 1;
    }
    for(i=0; i<n; i++){
        scanf("%100s", b);
        struct SN* nN = (struct SN*)malloc(sizeof(struct SN));
        strcpy(nN->ti, b);
        if(h == NULL){
            h = t = nN;
        }else{
            t->n = nN;
            nN->p = t;
            t = nN;
        }
    }
    if(h != NULL){
        t->n = h;
        h->p = t;
    }
    if(scanf("%d", &k) != 1){
        printf("Invalid input");
        if(h != NULL)
        f(h);
        return 1;
    }
    if(k>n || k<0){
        printf("Invalid input");
        if(h != NULL)
        f(h);
        return 1;
    }
    for(i=0; i<k; i++){
        h = h->n;
        t = t->n;
    }
    if(h != NULL){
        struct SN* c = h;
        for(i=0; i<n; i++){
            printf("%s", c->ti);
            if(i<n-1){
                printf(" ");
            }
            c = c->n;
        }
        printf("\n");
    }
    if(h != NULL){
        f(h);
    }
    return 0;
}