allCards :: [String]
allCards = map unwords $ sequence [["S" , "H" , "C" , "D"] , [show x | x <- [1..13] :: [Int]]]

solve :: [Int] -> String
solve [m,f,r]
    | m == -1 || f == -1 = "F"
    | m + f >= 80 = "A"
    | m + f >= 65 = "B"
    | m + f >= 50 = "C"
    | m + f >= 30 && r >= 50 = "C"
    | m + f >= 30 = "D"
    | otherwise = "F"

main :: IO ()
main  = getContents
    >>= return . takeWhile (/= [-1,-1,-1]) . map (map read) . map words . lines
    >>= return . map solve
    >>= mapM_ putStrLn