#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>

struct node{
    char data[101];
    struct node*prev;
    struct node*nxt;
    
};
struct node*cnode(char*data){
    struct node*newnode = (struct node*)malloc(sizeof(struct node));
    strcpy(newnode->data,data);
    newnode->prev = NULL;
    newnode->nxt = NULL;
    return newnode;
}
void append(struct node**head,char*data){
    struct node*newnode = cnode(data);
    if(*head == NULL){
        *head = newnode;
        return;
    }
    struct node*temp = *head;
    while (temp->nxt != NULL){
        temp = temp->nxt;
    }
    temp->nxt = newnode;
    newnode->prev = temp;
}
void deleteAtPosition(struct node**head,int pos,int n){
    if(pos < 0||pos >= n){
        printf("Invalid input\n");
        exit(0);
    }
    struct node*temp = *head;
    int index = 0;
    while(temp != NULL && index < pos){
        temp = temp->nxt;
        index+=;
    }
    else{
        temp->prev->nxt = temp->nxt;
        if(temp->nxt != NULL)
        temp->nxt->prev=temp->prev;
    }
    free(temp);
}
void printlist(struct node*head){
    if(head == NULL){
        printf("List is empty\n");
        return ;
    }
    struct node*temp = head;
    while(temp != NULL){
        printf("%s ",temp->data);
        temp = temp->nxt
    }
    int isValidname(char*str){
        if(!isalpha(str[0]))return 0;
        for(int i = 1; str[i] != '\0'; i++){
            if(!isalnum(str[i]))return 0;
        
        }
        return 1;
    }
    int main(){
        int n,pos;
        if(scanf("%d",&n) != 1 || n < 1 || n > 1000){
            printf("Invalid input\n");
            return 0;
        }
        struct node*head = NULL;
        for(int i = 0; i<n ; i++){
            char buffer[101];
            if(scanf("%s",buffer) != 1 || !isValidName(buffer)){
                printf("Invalid input\n");
                return 0;
            }
            append(&head,buffer);
        }
        if(scanf("%d",&pos) != 1){
            printf("Invalid input\n");
            return 0;
        }
        deletePosition(&head,pos,n);
        printlist(head);
        return 0;
    }
}