#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>
#include<numeric>
#include<cassert>

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

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); 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()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  int n;
  while(n = getInt()){
    REP(i,n){
      int pm = getInt();
      int pe = getInt();
      int pj = getInt();
      
      int sum = pm + pe + pj;
      
      if((pm == 100 || pe == 100 || pj == 100) ||
	 (pm + pe >= 180) || (sum >= 240)){
	puts("A");
      }else if((sum >= 210) || 
	       (sum >= 150 && (pm >= 80 || pe >= 80))){
	puts("B");
      }else{
	puts("C");
      }
    }
  }
  return 0;
}
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n, a, b, c;
	vector<char>l;
	while (true){
		cin >> n;
		if (n == 0){
			break;
		}
		else{
			for (int i = 0; i < n; i++){
				cin >> a >> b >> c;
				if (a == 100 || b == 100 || c == 100){
					l.push_back('A');
				}
				else if (a + b >= 180){
					l.push_back('A');
				}
				else if (a + b + c >= 240){
					l.push_back('A');
				}
				else if (a + b + c >= 210){
					l.push_back('B');
				}
				else if (a + b + c >= 150 && a >= 80){
					l.push_back('B');
				}
				else if (a + b + c >= 150 && b >= 80){
					l.push_back('B');
				}
				else l.push_back('C');
				a = 0;
				b = 0;
				c = 0;
			}
		}
	}
	for (int i = 0; i != l.size(); i++)
	{
		cout << l[i] << endl;
	}
}