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

main :: IO ()
main = interact (unlines . map solve . takeWhile (\xs -> any (\x -> x /= -1) xs) . map (map read . words) . lines)