#include <iostream>
using namespace std;

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0239

int cal(int p, int q, int r) {
	return (p + r) * 4 + q * 9;
}

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) break;
		int ad[n], ap[n], aq[n], ar[n];
		for (int i = 0; i < n; i++) {
			cin >> ad[i] >> ap[i] >> aq[i] >> ar[i];
		}
		int p, q, r, c;
		cin >> p >> q >> r >> c;
		int count = 0;
		for (int i = 0; i < n; i++) {
			if (ap[i] > p) continue;
			if (aq[i] > q) continue;
			if (ar[i] > r) continue;
			if (cal(ap[i], aq[i], ar[i]) > c) continue;
			cout << ad[i] << endl;
			count++;
		}
		if (count == 0) cout << "NA" << endl;
	}
	return 0;
}