#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
struct student{
char name[20];
char id[20];
int grade;
};
bool cmp(student a,student b){
return a.grade>b.grade;
}
int main(){
int n,low,high;
freopen("in.txt","r",stdin);
while(scanf("%d",&n)!=EOF){
vector <student> stu;
for(int i=0;i<n;i++){
student s;
scanf("%s %s %d",s.name,s.id,&s.grade);
stu.push_back(s);
}
scanf("%d %d",&low,&high);
if(low>high){
swap(low,high);
}
sort(stu.begin(),stu.end(),cmp);
int flag=0;
for(int i=0;i<stu.size();i++){
if(stu[i].grade>=low && stu[i].grade<=high){
flag=1;
printf("%s %s\n",stu[i].name,stu[i].id);
}
}
if(flag==0){
printf("NONE\n");
}
}
return 0;
}