#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <string>
#include <map>
using namespace std;

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()

using namespace std;

int main(){
    int n;
    while(cin>>n && n){
        bool na = true;
        int i[1000], p[1000], q[1000], r[1000];
        rep(j,n){
            cin>>i[j]>>p[j]>>q[j]>>r[j];
        }
        int pp,qq,rr,cc;
        cin>>pp>>qq>>rr>>cc;
        rep(j,n){
            if(p[j]<=pp && q[j]<=qq && r[j]<=rr && p[j]*4+q[j]*9+r[j]*4<=cc){
                na=false;
                cout<<i[j]<<endl;
            }
        }
        if(na){
            cout<<"NA"<<endl;
        }
    }
}    