main = interact $ unlines . solve . read' . lines
  where
    solve = map solveRow
    solveRow [a, b, c]
      | a == -1 || b == -1 = "F"
      | a + b >= 80 = "A"
      | a + b >= 65 = "B"
      | a + b >= 50 = "C"
      | a + b >= 30 && c >= 50 = "C"
      | a + b >= 30 = "D"
      | otherwise = "F"
    read' = map (map read . words) . init :: [String] -> [[Int]]

