module Main where
--import Debug.Trace
import Data.List
import Data.Array
import Data.Maybe
import Data.Ord
import Control.Monad

solve :: [[Int]] -> [String]
solve [] = []
solve ([m,f,r]:ds) = case [m,f,r] of
    [-1,_,_]    -> "F": solve ds
    [_,-1,_]    -> "F": solve ds
    _   | ts >= 80  -> "A": solve ds
        | ts >= 65  -> "B": solve ds
        | ts >= 50  -> "C": solve ds
        | ts >= 30 && r >= 50 -> "C": solve ds
        | ts >= 30  -> "D": solve ds
        | otherwise -> "F": solve ds where ts = m + f

readLine:: IO [Int]
readLine = fmap (map read . words) getLine

readUntil :: ([Int] -> Bool) -> IO [[Int]]
readUntil eof = iter where
    iter = readLine >>=
            (\a -> if eof a then return [] else fmap (a:) iter)
            
eof :: [Int] -> Bool
eof (m:f:r:xs) = all (<0) [m, f, r] 

main :: IO() 
main = do
    l   <- readUntil eof
    mapM_ putStrLn (solve l)

