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

int main(){
		int n;
		int j[1010], p[1010], q[1010], r[1010];
		int P, Q, R, C;

		while(cin >> n, n){
				bool isExist = false;
				for(int i=0; i < n; i++){
						cin >> j[i] >> p[i] >> q[i] >> r[i];
				}
				cin >> P >> Q >> R >> C;

				for(int i=0; i < n; i++){
						if(p[i]<=P && q[i]<=Q && r[i]<=R && (p[i]+r[i])*4+q[i]*9 <= C){
								cout << j[i] << endl;
								isExist = true;
						}
				}
				if(!isExist){
						cout << "NA" << endl;
				}
		}
}