Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	badge := []string{"AAA", "AA", "A", "B", "C", "D", "E"}
	badgeLen := len(badge)
	short := []float64{35.5, 37.5, 40, 43, 50, 55, 70}
	long := []float64{71, 77, 83, 89, 105, 116, 148}

	stdin := bufio.NewScanner(os.Stdin)
	for stdin.Scan() {
		time := strings.Split(stdin.Text(), " ")

		sT, _ := strconv.ParseFloat(time[0], 64)
		lT, _ := strconv.ParseFloat(time[1], 64)

		sR, lR, t := 0, 0, 0.0
		for _, t = range short {
			if sT < t {
				break
			}
			sR++
		}
		for _, t = range long {
			if lT < t {
				break
			}
			lR++
		}
		rank := ""
		if sR >= badgeLen || lR >= badgeLen {
			rank = "NA"
		} else if sR >= lR {
			rank = badge[sR]
		} else {
			rank = badge[lR]
		}
		fmt.Println(rank)
	}
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int chk500[8]={
  35, 37, 40, 43, 50, 55, 70, INT_MAX
};
int chk1000[8]={
  71, 77, 83, 89, 105, 116, 248, INT_MAX
};
const char *rank[8]={
  "AAA","AA","A","B","C","D","E","NA"
};

int main(){
  double a,b;
  while(~scanf("%lf%lf",&a,&b)){
    REP(i,8){
      if(i==7 || a < (double)chk500[i] && b < (double)chk1000[i]){
        puts(rank[i]);
        break;
      }
    }
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main(void){

	double a,b;
	while(cin >> a >> b){
		if(a<35.50 && b<71.0)cout << "AAA" << endl;
		else if(a<37.50 && b<77.0)cout << "AA" << endl;
		else if(a<40.0 && b<83.0)cout << "A" << endl;
		else if(a<43.0 && b<89.0)cout << "B" << endl;
		else if(a<50.0 && b<105.0)cout << "C" << endl;
		else if(a<55.0 && b<116.0)cout << "D" << endl;
		else if(a<70.0 && b<148.0)cout << "E" << endl;
		else cout << "NA" << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;

int main()
{
  double t1,t2;

  while(scanf("%lf %lf",&t1,&t2)!=EOF){

    if(t1<35.5 && t2<71.0)
      cout<<"AAA"<<endl;

    else if(t1<37.5 && t2<77.0)
      cout<<"AA"<<endl;

    else if(t1<40.0 && t2<83.0)
      cout<<"A"<<endl;

    else if(t1<43.0 && t2<89.0)
      cout<<"B"<<endl;

    else if(t1<50.0 && t2<105.0)
      cout<<"C"<<endl;

    else if(t1<55.0 && t2<116.0)
      cout<<"D"<<endl;

    else if(t1<70.0 && t2<148.0)
      cout<<"E"<<endl;

    else
      cout<<"NA"<<endl;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;

// infty
#define ULLINF (ULLONG_MAX)
#define LLINF  (LLONG_MAX)
#define IINF   (INT_MAX)
#define INF    (1<<29)

// math
#define Sq(x) ((x)*(x))

// container utility
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair
#define PB push_back
#define EACH(it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();it++)

// rep
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;

typedef long long ll;

// pair util
#define FST first
#define SND second

// range validator
#define CK(n,a,b) (a<=n && n<b)

// conversion
template<class T> inline string toStr(T a) { ostringstream oss_; oss_ << a; return oss_.str(); }
inline int toInt(string s) { return atoi(s.c_str()); }

// prime
bool isPrime(int a) { for(int i=2; i*i <=a; i++) if(a%i == 0) return false; return true; }

int const dx[] = {-1,0,1,0,-1,1,1,-1};
int const dy[] = {0,-1,0,1,-1,-1,1,1};

//////////////////////////////////////////////////////////////


double c(double a, double b) {
  return a*60+b;
}

int main() {
  
  double a, b;
  while(cin >> a >> b) {
    string res = "NA";
    if(a < c(1,10) && b < c(2,28)) res = "E";
    if(a < c(0,55) && b < c(1,56)) res = "D";
    if(a < c(0,50) && b < c(1,45)) res = "C";
    if(a < c(0,43) && b < c(1,29)) res = "B";
    if(a < c(0,40) && b < c(1,23)) res = "A";
    if(a < 37.5 && b < c(1,17)) res = "AA";
    if(a < 35.5 && b < c(1,11)) res = "AAA";

    cout << res << endl;
  }
  
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    double time[2];
    while(cin>>time[0]>>time[1]){
        if(time[0]<35.5&&time[1]<71)cout<<"AAA\n";
        else if(time[0]<37.5&&time[1]<77)cout<<"AA\n";
        else if(time[0]<40.0&&time[1]<83)cout<<"A\n";
        else if(time[0]<43.0&&time[1]<89)cout<<"B\n";
        else if(time[0]<50.0&&time[1]<105)cout<<"C\n";
        else if(time[0]<55.0&&time[1]<116)cout<<"D\n";
        else if(time[0]<70&&time[1]<148)cout<<"E\n";
        else cout<<"NA\n";
    }
}

C++: #include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>

using namespace std;


void Solution()
{
    double a,b;
    
    while(cin>>a>>b)
    {
        if(a < 35.5 && b < 71)
        {
            cout<<"AAA"<<endl;
        }
        else if(a < 37.5 && b < 77)
        {
            cout<<"AA"<<endl;
        }
        else if(a < 40 && b < 83)
        {
            cout<<"A"<<endl;
        }
        else if(a < 43 && b < 89)
        {
            cout<<"B"<<endl;
        }
        else if(a < 50 && b < 105)
        {
            cout<<"C"<<endl;
        }
        else if(a < 55 && b < 116)
        {
            cout<<"D"<<endl;
        }
        else if(a < 70 && b < 148)
        {
            cout<<"E"<<endl;
        }
        else
        {
            cout<<"NA"<<endl;
        }
    }
}

int main()
{
    Solution();
    return 0;
}

C++: #include <iostream>

using namespace std;

int main(void){
	double a,b;
	cin >> a >> b;
	if(a<35.5 && b<71.0)cout << "AAA" << endl;
	else if(a<37.5 && b<77.0)cout << "AA" << endl;
	else if(a<40.0 && b<83.0)cout << "A" << endl;
	else if(a<43.0 && b<89.0)cout << "B" << endl;
	else if(a<50.0 && b<105.0)cout << "C" << endl;
	else if(a<55.0 && b<116.0)cout << "D" << endl;
	else if(a<70.0 && b<148.0)cout << "E" << endl;
	else cout << "NA" << endl;
	return 0;
}

C++: // #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;

#define MP make_pair
#define fastIO	cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (未test)
// #define FOREACH_IT(it,c)	for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(), c_end=c.end(); it!=c_end; ++it)

// ------------------- include, typedef, define END. -------------------

void solve(double time500, double time1000){
	pair<double, double> timeList[7] = {
		MP(35.50,71.00),MP(37.50,77.00),MP(40.00,83.00),MP(43.00,89.00),
		MP(50.00,105.00),MP(55.00,116.00),MP(70.00,148.00)};
	string rank[7] = { "AAA", "AA", "A", "B", "C", "D", "E" };
	for (int i = 0; i < 7; i++){
		if (time500 < timeList[i].first && time1000 < timeList[i].second){
			cout << rank[i] << endl;
			return;
		}
	}
	cout << "NA" << endl;
	return;
}

int main(){
	double time500 = 0.0, time1000 = 0.0;
	while (cin >> time500 >> time1000){
		solve(time500, time1000);
	}
	return 0;
}