#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define int long long
using namespace std;
long long k=1000000007;

signed main(){
  int n;
  while(cin >> n,n){
    int s[n],p[n],q[n],r[n];
    for(int i=0;i<n;i++)cin >> s[i] >> p[i] >> q[i] >> r[i];
    int P,Q,R,C;
    cin >> P >> Q >> R  >> C;
    bool judge=true;
    for(int i=0;i<n;i++){
      if(p[i]<=P && q[i]<=Q && r[i]<=R && p[i]*4+q[i]*9+r[i]*4<=C){
      judge=false;
      cout << s[i] << endl;
      }
    }
    if(judge)
      cout << "NA" << endl;
  }
  
  return 0;
}