grad :: [Integer] -> String
grad (m:f:r:_) | m < 0 || f < 0 = "F"
               | m+f >= 80 = "A"
               | m+f >=65  = "B"
               | m+f >= 50 = "C"
               | r >= 50   = "C"
               | m+f >= 30 = "D"
               | otherwise = "F"
main = getContents >>= mapM_ (putStrLn . grad) . takeWhile (/=[-1,-1,-1]) . map (map read . words) . lines