#include <iostream>
using namespace std;

int main()
{
	int N;
	int s[1000], h[1000], L[1000], C[1000];
	while (cin >> N) {
		if (N == 0)
			break;
		for (int i = 0; i < N; i++) {
			cin >> s[i] >> h[i] >> L[i] >> C[i];
		}
		int P, Q, R, c;
		int a = 0;
		cin >> P >> Q >> R >> c;
		for (int i = 0; i < N; i++) {
			if ((h[i] <= P) && (L[i] <= Q) && (C[i] <= R) && ((h[i] * 4 + L[i] * 9 + C[i] * 4 )<= c)) {
				cout << s[i] << endl;
				a = 1;
			}
		}
		if (a == 0)
			cout << "NA" << endl;
	}
	return 0;
}