#include <iostream>
using namespace std;
int main(){
	int pm,pj,pe,n,i;
	while(cin >> n&&n){
		for(i=0;i<n;i++){
			cin >> pm >> pe >> pj;
			double ave = (pm+pe+pj)/3;
			if(pm == 100 || pe == 100 || pj == 100) cout << 'A' << endl;
			else if((pm+pe)/2 >= 90 || ave >= 80) cout << 'A' << endl;
			else if(ave >= 70) cout << 'B' << endl;
			else if(ave >= 50 && pe >= 80) cout << 'B' << endl;
			else if(ave >= 50 && pm >= 80) cout << 'B' << endl;
			else cout << 'C' << endl;
		}
	}
	return 0;
}