#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
using namespace std;
int main(){
int n;
while(cin>>n,n){
rep(i,n){
int a,b,c;
cin>>a>>b>>c;
if((a==100||b==100||c==100)||(a+b)/2>=90||a+b+c>=240)cout<<'A'<<endl;
else if(a+b+c>=210||(a+b+c>=150&&(a>=80||b>=80)))cout<<'B'<<endl;
else cout<<'C'<<endl;
}
}
}