#include <stdio.h>
#include <stdlib.h>
int main()
{
int d=0;
int m=0;
int n=0;
scanf_s("%d",&d);
struct node{
char info[20];
int no;
struct node*link;
};
struct node*head;
struct node*p1,*p2;
struct node*p;
n=0;
p1=p2=(struct node*)malloc(sizeof(struct node));
scanf("%s %d",&p1->info,&p1->no);
head=NULL;
while(n<=d){
n=n+1;
if(n==1)head=p1;
else p2->link=p1;
p2=p1;
p1=(struct node*)malloc(sizeof(struct node));
scanf("%s %d",&p1->info,&p1->no);}
p2->link=NULL;
scanf("%d",&m);
p=head;
if(head!=NULL)
do{
if(p->no>m)
printf("%s",p->info);
p=p->link;
}while (p!=NULL);
return 0;
}