#include<iostream>
using namespace std;
int main() {
  int n;
  while( cin >> n, n ) {
    int num[n], pro[n], lip[n], car[n];
    int p, q, r, c, cnt = 0;
    for(int i=0; i<n; i++) {
      cin >> num[i] >> pro[i] >> lip[i] >> car[i];
    }

    cin >> p >> q >> r >> c;
    for(int i=0; i<n; i++) {
      if( pro[i] <= p && lip[i] <= q && car[i] <= r ) {
	if( pro[i]*4 + lip[i]*9 + car[i]*4 <= c ) {
	  cout << num[i] << endl;
	  cnt++;
	}
      }
    }

    if( !cnt ) cout << "NA" << endl;
  }
}