until (a = $<.gets.split.map(&:to_i)) == [0, 0, 0]
  $<.gets.to_i.times.map {$<.gets.to_i}.each do |r|
    result = a.combination(2).map do |w, h|
      Math.sqrt((w / 2.0) ** 2 + (h / 2.0) ** 2) < r
    end.any?
    puts result ? "OK" : "NA"
  end
end

