#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c>>d;
    cin>>d;
    if(a<0 || a>100 || b<0 || b>100 || c<0 || c>100){
        cout<<"Invalid input";
        return 0;
    }
    int tot = a+b+c+d;
    if(tot >= 250){
        cout<<tot<<" "<<"A";
    }
    else if(tot >= 200 && tot<250){
        cout<<tot<<" "<<"B";
    }
    else if(tot>=150 && tot<200){
        cout<<tot<<" "<<"C";
    }
    else if(tot<150){
        cout<<tot<<" "<<"F";
    }
    else{
        cout<<"Invalid input";
    }
    return 0;
}