#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
struct student{
string name;
string id;
int score{};
};
bool cmp(student* s1,student* s2){
return s1->score>s2->score;
}
int main() {
int N;
int minS,maxS;
cin>>N;
vector<student*> students;
for (int i = 0; i < N; ++i) {
auto* student1=new student();
cin>>student1->name>>student1->id>>student1->score;
students.push_back(student1);
}
cin>>minS>>maxS;
vector<student*> res;
sort(students.begin(),students.end(),cmp);
for (auto s:students){
if(s->score>=minS&&s->score<=maxS){
res.push_back(s);
}
}
if(res.empty()){
cout<<"NONE"<<endl;
return 0;
}
for (auto & re : res) {
cout<<re->name<<" "<<re->id<<endl;
}
return 0;
}