Language: C++

#include <iostream>
#include <vector>

using namespace std;

int n;
class State
{
public:
	int i, p, q, r, c;
	State(int i, int p, int q, int r):i(i),p(p),q(q),r(r){}
};

vector<State> states;

int main()
{
	while (cin >> n && n)
	{
		states.resize(n);
		for (int j = 0; j < n; j++)
		{
			int i, p, q, r;
			cin >> states[j].i >> states[j].p >> states[j].q >> states[j].r;
			states[j].c = states[j].p * 4 + states[j].q * 4 + states[j].r * 9;
		}
		int mp, mq, mr, mc;
		cin >> mp >> mq >> mr >>mc;
		bool flag = true;
		for (int j = 0; j < n; j++)
		{
			if(states[j].p <= mp && states[j].q <= mq &&states[j].r <= mr && states[j].c <= mc)
			{
				flag = false;
				cout << states[j].i;
			}
		}
		if(flag) cout << "NA" << endl;
	}
	return 0;
}

Compiler output:
In file included from /usr/include/c++/14/bits/alloc_traits.h:33,
                 from /usr/include/c++/14/ext/alloc_traits.h:34,
                 from /usr/include/c++/14/bits/basic_string.h:39,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_construct.h: In instantiation of 'void std::_Construct(_Tp*, _Args&& ...) [with _Tp = State; _Args = {}]':
/usr/include/c++/14/bits/stl_uninitialized.h:643:18:   required from 'static _ForwardIterator std::__uninitialized_default_n_1<_TrivialValueType>::__uninit_default_n(_ForwardIterator, _Size) [with _ForwardIterator = State*; _Size = long unsigned int; bool _TrivialValueType = false]'
  643 |                 std::_Construct(std::__addressof(*__cur));
      |                 ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_uninitialized.h:712:20:   required from '_ForwardIterator std::__uninitialized_default_n(_ForwardIterator, _Size) [with _ForwardIterator = State*; _Size = long unsigned int]'
  710 |       return __uninitialized_default_n_1<__is_trivial(_ValueType)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  711 |                                          && __can_fill>::
      |                                          ~~~~~~~~~~~~~~~~
  712 |         __uninit_default_n(__first, __n);
      |         ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_uninitialized.h:779:44:   required from '_ForwardIterator std::__uninitialized_default_n_a(_ForwardIterator, _Size, allocator<_Tp>&) [with _ForwardIterator = State*; _Size = long unsigned int; _Tp = State]'
  779 |     { return std::__uninitialized_default_n(__first, __n); }
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:821:35:   required from 'void std::vector<_Tp, _Alloc>::_M_default_append(size_type) [with _Tp = State; _Alloc = std::allocator<State>; size_type = long unsigned int]'
  821 |                 std::__uninitialized_default_n_a(this->_M_impl._M_finish,
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
  822 |                                                  __n, _M_get_Tp_allocator());
      |                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1016:4:   required from 'void std::vector<_Tp, _Alloc>::resize(size_type) [with _Tp = State; _Alloc = std::allocator<State>; size_type = long unsigned int]'
 1016 |           _M_default_append(__new_size - size());
      |           ^~~~~~~~~~~~~~~~~
a.cc:20:16:   required from here
   20 |                 states.resize(n);
      |                 ~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_construct.h:119:7: error: no matching function for call to 'State::State()'
  119 |       ::new((void*)__p) _Tp(std::forward<_Args>(__args)...);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:11:9: note: candidate: 'State::State(int, int, int, int)'
   11 |         State(int i, int p, int q, int r):i(i),p(p),q(q),r(r){}
      |         ^~~~~
a.cc:11:9: note:   candidate expects 4 arguments, 0 provided
a.cc:7:7: note: candidate: 'constexpr State::State(const State&)'
    7 | class State
      |       ^~~~~
a.cc:7:7: note:   candidate expects 1 argument, 0 provided
a.cc:7:7: note: candidate: 'constexpr State::State(State&&)'
a.cc:7:7: note:   candidate expects 1 argument, 0 provided