#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	int a, b, c, n, tmp;
	
	while(1){
		cin >> a >> b >> c;
		if(a == 0){
			break;
		}
		cin >> n;
		for(int i = 0; i < n; i++){
			cin >> tmp;
			if(tmp >= a || tmp >= b || tmp >= c){
				cout << "OK" << endl;
			} else {
				cout << "NA" << endl;
			}
		}
	}
	
	return 0;
}