#include <iostream>
using namespace std;

int main()
{
	int n;
	while(cin >> n){
		if(n==0)
			break;
		int a[1000],b[1000],c[1000],d[1000];
		for(int i=0;i<n;i++){
			cin >> a[i] >> b[i] >> c[i] >> d[i];
		}
		int B,C,D,cal;
		cin >> B >> C >> D >> cal;
		bool flag = false;
		for(int i=0;i<n;i++){
			if(b[i]<=B && c[i]<=C && d[i]<=D && b[i]*4+c[i]*9+d[i]*4<=cal){
				flag = true;
				cout << a[i] << endl;
			}
		}
		if(!flag)
			cout << "NA" << endl;
	}
	return 0;
}