#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct Node 
{
    char data[100];
    struct Node *prev;
    struct Node *next;
};
void insertEnd(struct Node **head,char str[]) 
{
    struct Node newNode=(struct Node)malloc(sizeof(struct Node));
    struct Node *last=*head;

    strcpy(newNode->data,str);
    newNode->next=NULL;
    newNode->prev=NULL;

    if(*head==NULL) 
    {
        *head=newNode;
        return;
    }
    while(last->next!=NULL)
        last=last->next;

    last->next=newNode;
    newNode->prev=last;
}
void deleteAtPos(struct Node **head,int pos) {
    struct Node* temp=*head;
    int i;
    if(*head==NULL||pos<0) 
    {
        printf("List is empty\n");
        return;
    }
    for(i=0;temp!=NULL&&i<pos;i++) 
    {
        temp=temp->next;
    }
    if(temp==NULL)
    {
        printf("List is empty\n");
        return;
    }
    if(temp->prev==NULL)
        *head=temp->next;
    else
        temp->prev->next=temp->next;
    if (temp->next!=NULL)
        temp->next->prev=temp->prev;
    free(temp);
}
void printList(struct Node  *head) 
{
    if(head==NULL)
    {
        printf("List is empty");
        return;
    }
    struct Node *temp=head;
    while(temp!=NULL) 
    {
        printf("%s ",temp->data);
        temp=temp->next;
    }
    printf("\n");
}

int main() 
{
    struct Node *head=NULL;
    int n,pos;
    char str[100];
    scanf("%d",&n);
    if(n<=0)
    {
        printf("List is empty");
        return 0;
    }
    for(int i=0;i<n;i++) 
    {
        scanf("%s",str);
        insertEnd(&head, str);
    }
    scanf("%d",&pos);
    if(pos>=n)
    {
        printf("Invalid input");
        return 0;
    }
    deleteAtPos(&head,pos);
    printList(head);

    return 0;
}