#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main(void){
	int n;
	while(cin>>n,n){
		int name[1024],p[1024],q[1024],r[1024],c[1024];
		for(int i=0,it,pt,qt,rt;i<n;++i){
			cin>>it>>pt>>qt>>rt;
			name[i]=it;
			p[i]=pt;
			q[i]=qt;
			r[i]=rt;
			c[i]=pt*4+qt*9+rt*4;
		}
		int lp,lq,lr,lc;//limit
		cin>>lp>>lq>>lr>>lc;
		bool f=false;
		for(int i=0;i<n;++i){
			if(p[i]<=lp&&q[i]<=lq&&r[i]<=lr&&c[i]<=lc){
				f=true;
				cout<<name[i]<<endl;
			}
		}
		if(!f)cout<<"NA"<<endl;
	}
	return 0;
}