#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
struct Node 
{
    char chapter[101];
    struct Node *next;
    struct Node *prev;
};
struct Node* newNode(char *chapter) 
{
    struct Node* node = (struct Node*) malloc(sizeof(struct Node));
    strcpy(node->chapter, chapter);
    node->next = NULL;
    node->prev = NULL;
    return node;
}
int startsWithAlphabet(char *str) 
{
    return (isalpha((unsigned char)str[0]));
}
int main() 
{
    int h;
    scanf("%d", &h);
    struct Node *head = NULL, *tail = NULL;
    for (int i = 0; i < h; i++) 
    {
        char temp[101];
        scanf("%s", temp);
        if (!startsWithAlphabet(temp)) 
        {
            printf("Invalid input");
            return 0;
        }
        struct Node *node = newNode(temp);
        if (head == NULL) 
        {
            head = tail = node;
        } 
        else 
        {
            tail->next = node;
            node->prev = tail;
            tail = node;
        }
    }
    int s;
    scanf("%d", &pos);
    if (pos < 0 || s >= h) 
    {
        printf("Invalid input");
        return 0;
    }
    struct Node *current = head;
    for (int i = 0; i < s; i++) 
    {
        current = current->next;
    }
    if (current == head) 
    {
        head = head->next;  
        if (head != NULL) 
        {
            head->prev = NULL;
        } 
        else 
        {
            tail = NULL; 
        }
    } 
    else if (current == tail)
    {
        tail = tail->prev;
        tail->next = NULL;
    } 
    else 
    {
        current->prev->next = current->next;
        current->next->prev = current->prev;
    }
    free(current);
    h--;
    if (head == NULL) 
    {
        printf("List is empty");
    } 
    else 
    {
        struct Node *ptr = head;
        while (ptr != NULL)
        {
            printf("%s", ptr->chapter);
            if (ptr->next != NULL) printf(" ");
            ptr = ptr->next;
        }
    }
    return 0;
}