import           Control.Applicative
import           Control.Monad

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

main :: IO ()
main = do
    xss <- fmap (fmap read . words) . lines <$> getContents :: IO [[Int]]
    let yss = takeWhile (/= [-1, -1, -1]) xss
    forM_ yss $ \ys -> do
        putStrLn $ grade ys

