Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}
		for i := 0; i < n; i++ {
			scanner.Scan()
			buf := strings.Split(scanner.Text(), " ")
			math, _ := strconv.Atoi(buf[0])
			english, _ := strconv.Atoi(buf[1])
			japanese, _ := strconv.Atoi(buf[2])
			if math == 100 || english == 100 || japanese == 100 {
				fmt.Println("A")
			} else if math + english >= 180 {
				fmt.Println("A")
			} else if math + english + japanese >= 240 {
				fmt.Println("A")
			} else if math + english + japanese >= 210 {
				fmt.Println("B")
			} else if math + english + japanese >= 150 && (math >= 80 || english >= 80) {
				fmt.Println("B")
			} else {
				fmt.Println("C")
			}
		}
	}
}

C++: #include <iostream>

char detClass(int pm, int pe, int pj)
{
	
	int mean = pm + pe + pj;
	if((pm == 100) | (pe == 100) | (pj == 100)) {
		return 'A';
	} else if( (pm + pe) >= 180) {
		return 'A';
	} else if( mean >= 240) {
		return 'A';
	} else if( mean >= 210) {
		return 'B';
	} else if( (mean >= 150) && ((pm >= 80) | (pe >= 80))) {
		return 'B';
	} else {
		return 'C';
	}
}

int main()
{
	int n, pm, pe, pj = 0;
	
	while(true) {
		std::cin >> n;
		if(n == 0) {
			break;
		}
		for(int i = 0; i < n; i++) {
			std::cin >> pm >> pe >> pj;
			std::cout << detClass(pm,pe,pj) << std::endl;
		}
	}
	return 0;	
}

C++: #include<stdio.h>
int main(void)
{
	int a,s,d,f,i;
	scanf("%d",&a);
	while(a!=0){
		for(i=1;i<=a;i++){
			scanf("%d %d %d",&s,&d,&f);
			if(s==100 || d==100 || f==100){
				printf("A\n");
			}
			else if((s+d+f)/3>=80){
				printf("A\n");
			}
			else if((s+d)/2>=90){
				printf("A\n");
			}
			else if((s+d+f)/3>=70){
				printf("B\n");
			}
			else if((s+d+f)/3>=50 && s>=80 || d>=80){
				printf("B\n");
			}
			else{
				printf("C\n");
			}
		}
	scanf("%d",&a);
	}
	return 0;
}

C++: #include <stdio.h>
#include <stdbool.h>
void judge(int pe, int pm, int pj);
int main(void)
{
    int n, pe, pm, pj;
    while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }
        for (int i = 0; i < n; ++i) {        
            scanf("%d %d %d", &pe, &pm, &pj);
            judge(pe, pm, pj);
        }
    }
}
void judge(int pe, int pm, int pj)
{
    int sum = pe + pm + pj;
    int sumem = pe + pm;
    bool flag2 = false;
    if (pm >= 80 || pe >= 80) {
        flag2 = true;
    }
    if(pe == 100 || pj == 100 || pm == 100 || sum >= 240 || sumem >= 180) {
        printf("A\n");
    } else if (sum >= 210) {
        printf("B\n");
    } else if (sum >= 150 && flag2 == true) {
        printf("B\n");
    } else {
        printf("C\n");
    }
}

C++: #include <stdio.h>

void judge(int pm, int pe, int pj);

int main(void)
{
    int dataset;
    int pm, pe, pj;

    while (1){
        scanf("%d", &dataset);
        if (dataset == 0){
            break;
        } else {
            while (dataset--){
                scanf("%d %d %d", &pm, &pe, &pj);
                judge(pm, pe, pj);
            }
        }
    }

    return 0;
}

void judge(int pm, int pe, int pj)
{
    int sum = pm + pe + pj;
    char class;

    if (pm == 100 || pe == 100 || pj == 100){
        class = 'A';
    } else if (pm + pe >= 180){
        class = 'A';
    } else if (sum >= 240){
        class = 'A';
    } else if (sum >= 210){
        class = 'B';
    } else if (sum >= 150 && (pm >= 80 || pe >= 80)){
        class = 'B';
    } else {
        class = 'C';
    }

    printf("%c\n", class);
}

C++: #include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
#define LDcout(x,n) fixed<<setprecision(n)<<x

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	while(cin>>n,n){
		rep(i,n){
			vint v(3);
			rep(j,3) cin>>v[j];
			vint w=v;
			sort(ALL(w));
			if(w[2]==100) cout<<"A"<<endl;
			else if(v[0]+v[1]>=180) cout<<"A"<<endl;
			else if(v[0]+v[1]+v[2]>=240) cout<<"A"<<endl;
			else if(v[0]+v[1]+v[2]>=210) cout<<"B"<<endl;
			else if(v[0]+v[1]+v[2]>=150&&max(v[0],v[1])>=80) cout<<"B"<<endl;
			else cout<<"C"<<endl;
		}
	}
}


signed main() {
	ios_base::sync_with_stdio(false);
    cin.tie(0);
  	cout<<fixed<<setprecision(20);
    mainmain();
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  int n,s,i,a,b,c;
  while(cin>>s,s){
  cin>>n;
  while(n--){
    cin>>a>>b>>c;
    if(a==100||b==100||c==100||b+c>179||a+b+c>239)cout<<'A'<<endl;
    else if(a+b+c>209||(a+b+c>149&&(a>79||c>79)))cout<<'B'<<endl;
    else cout<<'C'<<endl;
  }}
}

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>
#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;
}