-- Structured Program II - Grading

import Control.Applicative

main :: IO ()
main = do
  xs <- map (map read . words) . lines <$> getContents
  mapM_ (putStrLn . calc) $ takeWhile (/= [-1, -1, -1]) xs

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

