import Control.Monad
import Data.List

input :: IO (Maybe ([Integer] , [Integer]))
input = do
    abc <- getLine >>= return . map read . words
    if any (== 0) abc then
        return Nothing
    else do
        n <- readLn
        xs <- replicateM n readLn
        return $ Just (abc , xs)

isOK :: [Integer] -> Integer -> Bool
isOK abc r = w ^ 2 + h ^ 2 < r2 ^ 2
    where
        w:h:_ = sort abc
        r2 = r * 2

solve :: [Integer] -> [Integer] -> IO ()
solve abc = mapM_ putStrLn . map (toStr . isOK abc)
    where
        toStr x = if x then "OK" else "NA"

main :: IO ()
main  = input
    >>= maybe (return ()) (\ s -> uncurry solve s >> main)