main = mapM_ process . takeWhile (/= "-1 -1 -1") . lines =<< getContents
  where process line = do
                          putStrLn $ grade m f r
                          where [m,f,r] = map (read::String->Int) $ words line
                                grade m f r
                                  | m==(-1) || f==(-1) ="F"
                                  | m+f>=80 = "A"
                                  | m+f>=65 && m+f<80 ="B"
                                  | m+f>=50 && m+f<65 ="C"
                                  | m+f>=30 && m+f<50 && r>=50 ="C"
                                  | m+f>=30 && m+f<50 && r<50 ="D"
                                  | m+f<30 ="F"