import Control.Applicative
import Control.Monad

main = do
    rect <- map read.words<$>getLine
    if all ( == 0) rect then return ()
                        else do
                            n       <- readLn
                            rs   <- replicateM n readLn
                            mapM_ putStrLn $ map (printResult rect) $ rs
                            main

printResult :: [Double] -> Double -> String
printResult rect r = if rect `isAbleToThrough` r then "OK"
                                                 else "NA"

isAbleToThrough :: [Double] -> Double -> Bool
isAbleToThrough [d,w,h] r = minLength < r
    where minLength = minimum $ map halfDiag [(d,w),(d,h),(w,h)]
          halfDiag (x,y) = (sqrt (x^2 + y^2)) / 2