#include<iostream>
using namespace std;

int main(void){
	int n, s, p, q, r, P, Q, R, C;
	
	while(1){
		cin >> n;
		int S[n][4];
		if(n == 0)break;
		for(int i = 0; i < n; i++){
			cin >> s >> p >> q >> r;
			S[i][0] = s;
			S[i][1] = p;
			S[i][2] = q;
			S[i][3] = r;
		}
		cin >> P >> Q >> R >> C;
		int j = 0;
		for(int i = 0; i < n; i++){
			if(S[i][1] <= P && S[i][2] <= Q && S[i][3] <= R && (S[i][1]*4 + S[i][2]*9 + S[i][3]*4) <= C){
				cout << S[i][0] << endl;
				j = 1;
			}
		}
		if(j == 0)cout << "NA" << endl;
	}
	return 0;
}
