judge :: Double -> Double -> String
judge t u
    | t < 35.50 && u < 71.00 = "AAA"
    | t < 37.50 && u < 77.00 = "AA"
    | t < 40.00 && u < 83.00 = "A"
    | t < 43.00 && u < 89.00 = "B"
    | t < 50.00 && u < 105.00 = "C"
    | t < 55.00 && u < 116.00 = "D"
    | t < 70.00 && u < 148.00 = "E"
    | otherwise               = "NA"

main :: IO ()
main = interact $ unlines . map (\[t, u] -> judge t u) . map (map read) . map words . lines