#!/usr/bin/env ruby
# encoding: UTF-8
loop do
  edges = gets.split.map(&:to_i)
  break if edges.all?{|i| i.zero?}
  phi_squared = edges.sort.take(2).reduce(0){|m, i| m += i**2}
  n = gets.to_i
  n.times do
    r = gets.to_i
    puts phi_squared < (2*r)**2 ? "OK" : "NA"
  end
end
