#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
using namespace std;
struct node {
string name, id;
int grade;
};
bool cmp(node a, node b){
return a.grade >= b.grade;
}
int main(){
int n, s, e;
cin >> n;
vector<node> nodes(n), v;
for (int i = 0; i < n; i++) {
string a, b; int grade;
cin >> a >> b >> grade;
nodes[i] = {a, b, grade};
}
cin >> s >> e;
for (int i = 0; i < n; i++) {
if (nodes[i].grade >= s && nodes[i].grade <= e)
v.push_back(nodes[i]);
}
if (v.size() > 0) {
sort(v.begin(), v.end(), cmp);
for (int i = 0; i < v.size(); i++) {
cout << v[i].name << ' ' << v[i].id << endl;
}
}else{
cout << "NONE\n";
}
return 0;
}