main :: IO ()
main = interact $ unlines . map (eval . map read . words) . init . lines

eval :: [Int] -> String
eval [m,f,r]
    | m == -1 || f == -1 || s < 30 = "F"
    | s >= 80 = "A"
    | s >= 65 = "B"
    | s >= 50 || r >= 50 = "C"
    | otherwise = "D"
    where s = m + f
