#include <iostream>
#include <cstdio>
using namespace std;

int II[1000] , PP[1000] , QQ[1000] , RR[1000];
int main(){
	int n;
	while(cin >> n && n){
		int x = 0;
		for(int i = 0 ; i < n ; i++){
			cin >> II[i] >> PP[i] >> QQ[i] >> RR[i];
		}
		int P,Q,R,C,k=0;
		cin >> P >> Q >> R >> C;
		for(int i = 0 ; i < n ; i++){
			if(PP[i] <= P && QQ[i] <= Q && RR[i] <= R && PP[i] * 4 + RR[i] * 4 + QQ[i] * 9 <= C){
				cout << II[i] << endl;
				k++;
			}
		}
		if(!k) cout << "NA" << endl;
	}
}