#include<iostream>
#include<cmath>
using namespace std;
int main(){
long a,b,c,n,x,i;
while(cin>>a){
cin>>b>>c>>n;
if(a==0)break;
a=min(min(a,b),c);
for(i=0;i<n;i++){
cin>>x;
if(x>=a)cout<<"OK"<<endl;
else cout<<"NA"<<endl;
}
}
return 0;
}