solve :: [Int] -> [String]
solve (m:f:r:xs)
  | null xs = []
  | m == -1 || f == -1 = "F" : solve xs
  | m + f >= 80 = "A" : solve xs
  | m + f >= 65 && 80 > m + f = "B" : solve xs
  | m + f >= 50 && 65 > m + f = "C" : solve xs
  | m + f >= 30 && 50 > m + f = (if r >= 50 then "C" else "D") : solve xs
  | otherwise =	"F" : solve xs

main = getContents >>= mapM_ putStrLn . solve . map read	. words	