#include<cstdio>
#include<iostream>
using namespace std;
int main(void){
	int n,s[1000],p[1000],q[1000],r[1000],cal[1000],i,a,b,c,d,flg;
	while(1){
		cin>>n;
		if(n==0) break;
		for(i=0;i<n;i++){
			cin>>s[i]>>p[i]>>q[i]>>r[i];
			cal[i]=(p[i]+r[i])*4+q[i]*9;
		}
		cin>>a>>b>>c>>d;
		flg=0;
		for(i=0;i<n;i++){
			if(a>=p[i]&&b>=q[i]&&c>=r[i]&&d>=cal[i]){
				flg=1;
				cout<<s[i]<<endl;
			}
		}
		if(flg==0) cout<<"NA"<<endl;
	}
	return 0;
}