main = getContents >>= putOut.formatOut.map calc.formatIn
  where putOut s | null s || last s == '\n' = putStr s
                 | otherwise                = putStrLn s
  
formatIn :: String -> [[Int]]
formatIn =  map ((map (read :: String -> Int)).words).takeWhile (/= "-1 -1 -1").lines

formatOut :: [String] -> String
formatOut = unlines

calc :: [Int] -> String
calc (m:f:r:_)
    | m == -1 || f == -1 || p < 30 = "F"
    | p >= 80                      = "A" 
    | p >= 65 && p < 80            = "B"
    | p >= 50 && p < 65 || r >= 50 = "C"
    | otherwise                    = "D"
  where p = m + f