#include<iostream>
using namespace std;

int main() {
	int n;
	while (cin >> n, n) {
		int ia[1000], p[1000], q[1000], r[1000];
		for (int j = 0;j < n;j++) {
			cin >> ia[j] >> p[j] >> q[j] >> r[j];
		}
		int mp, mq, mr, mc;
		cin >> mp >> mq >> mr >> mc;

		int flg = 0;
		for (int i = 0;i < n;i++) {
			int kc = p[i] * 4 + (q[i] * 9) + (r[i] * 4);
			if (p[i] <= mp && q[i] <= mq&& r[i] <= mr && kc <= mc) {
				flg = 1;
				cout << ia[i] << endl;
			}
		}
		if (flg == 0)cout << "NA" << endl;
	}
	return 0;
}