#include <stdio.h>
#include <stdlib.h>
#define len sizeof(struct student)
struct student
{
char name[20];
int age;
struct student *next;
};
struct student *creat(int n){
struct student *head,*p1,*p2;
int i=0;
p1=p2=(struct student *)malloc(len);
scanf("%s %d",&p1->name,&p1->age);
while(i<=n-1)
{
i++;
if(i==1) head=p1;
else p2->next=p1;
p2=p1;
if(i>n-1)
continue;
p1=(struct student *)malloc(len);
scanf("%s %d",&p1->name,&p1->age);
//printf("%s %d",p1->name,p1->age);
}
p2->next=NULL;
return head;
}
struct student *del(struct student *head,int num){
struct student *p1,*p2;
p1=head;
while(p1->next!=NULL){
while(p1->age!=num&&p1->next!=NULL)
{
p2=p1;
p1=p1->next;
}
if(p1->age==num)
{
if(p1==head) head=p1->next;
else p2->next=p1->next;
p1=p2;
}
}
return head;
}
int main(){
int n,i;
struct student *p;
int old;
scanf("%d",&n);
p=creat(n);
scanf("%d",&old);
p=del(p,old);
while(p){
printf("%s",p->name);
if(p->next)
printf(" ");
p=p->next;
}
return 0;
}