Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	m500 := []float64{35.5, 37.5, 40.0, 43.0, 50.0, 55.0, 70.0, 1000.0}
	m1000 := []float64{71.0, 77.0, 83.0, 89.0, 105.0, 116.0, 148.0, 1000.0}
	classes := []string{"AAA", "AA", "A", "B", "C", "D", "E", "NA"}
	for scanner.Scan() {
		input := strings.Split(scanner.Text(), " ")
		t500, _ := strconv.ParseFloat(input[0], 64)
		t1000, _ := strconv.ParseFloat(input[1], 64)
		for i := 0; i < len(m500); i++ {
			if t500 < m500[i] && t1000 < m1000[i] {
				fmt.Println(classes[i])
				break
			}
		}
	}
}

C++: /*
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;

struct IND{string str,int page;};
int main()
{

struct IND N1[101]={};
string R;
int x,i=0;
while(scanf("%s %d",&R,&x)!=EOF){
N1[i].str=R;N1[i].page=x;i++;
}
for(int j=0;j<i;j++)
{
	for(int k=i;k>=j;k--)
	{
	*/
#include<stdio.h>
#include<iostream>
using namespace std;
void TR(double x,double y,int K,int H)
{

double t;
t=x*100;
if(t<3550)K=0;
else if(t<3550)K=0;
else if(t<3750)K=1;
else if(t<4000)K=2;
else if(t<4300)K=3;
else if(t<5000)K=4;
else if(t<5500)K=5;
else if(t<7000)K=6;
else if(t>=7000)K=7;

t=y*100;
if(t<3550)K=0;
else if(t<7100)H=0;
else if(t<7700)H=1;
else if(t<8300)H=2;
else if(t<8900)H=3;
else if(t<10500)H=4;
else if(t<11600)H=5;
else if(t<14800)H=6;
else if(t>=14800)H=7;
cout<<t;
}



int main(){
int K=0,H=0;
double x,y;
while(scanf("%lf %lf",&x,&y)!=EOF)
{K=0,H=0;

//TR(x,y,K,H);cout<<H<<K;
int t=0;
double X;
X=x*100;t=(int)X;

if(t<3550)K=0;
else if(t<3550)K=0;
else if(t<3750)K=1;
else if(t<4000)K=2;
else if(t<4300)K=3;
else if(t<5000)K=4;
else if(t<5500)K=5;
else if(t<7000)K=6;
else if(t>=7000)K=7;

X=y*100;t=(int)X;
if(t<3550)K=0;
else if(t<7100)H=0;
else if(t<7700)H=1;
else if(t<8300)H=2;
else if(t<8900)H=3;
else if(t<10500)H=4;
else if(t<11600)H=5;
else if(t<14800)H=6;
else if(t>=14800)H=7;


if(H<K)H=K;

switch(K){
case 0:
cout<<"AAA"<<endl;break;
case 1:
cout<<"AA"<<endl;break;
case 2:
cout<<"A"<<endl;break;
case 3:
cout<<"B"<<endl;break;
case 4:
cout<<"C"<<endl;break;
case 5:
cout<<"D"<<endl;break;
case 6:
cout<<"E"<<endl;break;
case 7:
cout<<"NA"<<endl;break;

}
}
return 0;
}

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

#define pb push_back
#define fr first
#define sc second
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> pip; 
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){

  double a ,b;
  while(scanf("%lf %lf",&a,&b) != EOF){
    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;
  }
}

C++: #include <iostream>
using namespace std;
int main(){

	double a,b;

	cin >> a >> b;

	if(a<35.50 && b<71.00){

		cout << "AAA";
	}

	else if(a<37.50 && b<77.00){
		cout << "AA";
	}

	else if(a<40.00 && b<83.00){

		cout << "A";
	}

	else if(a<43.00 && b<89.00){

		cout << "B";
	}
	else if(a<50.00 && b<105.00){
		cout << "C";
	}
	else if(a<55.00 && b<116.00){
		cout << "D";
	}
	else if(a<70.00 && b<148.00){

		cout << "E";
	}
	else{
		cout << "NA";
	}
	return 0;
}

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

double m500, m1000;

void solve(){
	if(m500 >= 70.00 || m1000 >= 148.00) cout << "NA" << endl;

	else if(m500 >= 55.00 || m1000 >= 116.00) cout << "E" << endl;

	else if(m500 >= 50.00 || m1000 >= 105.00) cout << "D" << endl;

	else if(m500 >= 43.00 || m1000 >= 89.00) cout << "C" << endl;

	else if(m500 >= 40.00 || m1000 >= 83.00) cout << "B" << endl;

	else if(m500 >= 37.50 || m1000 >= 77.00) cout << "A" << endl;

	else if(m500 >= 35.50 || m1000 >= 71.00) cout << "AA" << endl;

	else cout << "AAA" << endl;
}

int main(){
	while(cin >> m500 >> m1000){
		solve();
	}
}

C++: // Tazoe

#include <iostream>
using namespace std;

int main()
{
while(true){
	double t500, t1000;
	cin >> t500;
if(cin.eof())
break;
	cin >> t1000;

	if(t500<35.5&&t1000<71.0){
		cout << "AAA" << '\n';
	}
	else if(t500<37.5&&t1000<77.0){
		cout << "AA" << '\n';
	}
	else if(t500<40.0&&t1000<83.0){
		cout << "A" << '\n';
	}
	else if(t500<43.0&&t1000<89.0){
		cout << "B" << '\n';
	}
	else if(t500<50.0&&t1000<105.0){
		cout << "C" << '\n';
	}
	else if(t500<55.0&&t1000<116.0){
		cout << "D" << '\n';
	}
	else if(t500<70.0&&t1000<148.0){
		cout << "E" << '\n';
	}
	else{
		cout << "NA" << '\n';
	}
}
	return 0;
}

C++: #include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
 
int main(){
  double R5,R10;
 
  while(cin >> R5 >> R10){
    if(R5 < 35.50 && R10 < 71.00){
      cout << "AAA" << endl;
    }
    else if(R5 < 37.50 && R10 < 77.00){
      cout << "AA" << endl;
    }
    else if(R5 < 40.00 && R10 < 83.00){
      cout << "A" << endl;
    }
    else if(R5 < 43.00 && R10 < 89.00){
      cout << "B" << endl;
    }
    else if(R5 < 50.00 && R10 < 105.00){
      cout << "C" << endl;
    }
    else if(R5 < 55.00 && R10 < 116.00){
      cout << "D" << endl; 
    }
    else if(R5 < 70.00 && R10 < 148.00){
      cout << "E" << endl;
    }
    else{
      cout << "NA" << endl;
    }
 
  }
  return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

int f(double x) {
  return (x < 70.0) + (x < 55.0) + (x < 50.0) + (x < 43.0) +
         (x < 40.0) + (x < 37.0) + (x < 35.5);
}

int g(double x) {
  return (x < 148.0) + (x < 116.0) + (x < 105.0) + (x < 89.0) +
         (x < 83.0) + (x < 77.0) + (x < 71.0);
}

void solve() {
  double t1, t2;
  string t[] = {"NA", "E", "D", "C", "B", "A", "AA", "AAA"};
  while (cin >> t1 >> t2) {
    cout << t[min(f(t1), g(t2))] << endl;
  }
}