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>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair
int main(){
  int n;
  while(cin>>n,n){
    for(int i=0;i<n;i++){
      int a,b,c;
      cin>>a>>b>>c;
      if(a==100||b==100||c==100)cout<<'A'<<endl;
      else if(a+b>=180)cout<<'A'<<endl;
      else if(a+b+c>=240)cout<<'A'<<endl;
      else if(a+b+c>=210)cout<<'B'<<endl;
      else if(a+b+c>=150&&(a>=80||b>=80))cout<<'B'<<endl;
      else cout<<'C'<<endl;
    }
  }
}

C++: 
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int gcd( int x, int y ){ return y ? gcd(y, x%y) : x; }
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
int a=0,b=-1,c=0,d=0;
while (true) {
  std::cin >> n;
  if(n==0)break;
  std::vector<string> v;
rep(i,n){
  std::cin >> x>>y>>z;
if(x==100||y==100||z==100) v.pb("A");
else if((x+y)/2>=90)v.pb("A");
else if((x+y+z)/3>=80)v.pb("A");
else if((x+y+z)/3>=70)v.pb("B");
else if((x+y+z)/3>=50&&(x>=80||y>=80))v.pb("B");
else v.pb("C");
  }
rep(i,n)std::cout << v[i] << '\n';
}
  }

C++: #include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

char school(int m, int e, int j)
{
if( m == 100 || e == 100 || j == 100 )
        return 'A';
    if( (m+e)>=180 || (m+e+j)>=240)
        return 'A';
    if( (m+e+j)>=210 || ( (m+e+j)>=150 && (m>=80||e>=80) ) )
		return 'B';
	else
    return 'C';
}
int main()
{
	int x, m, e, j;
	while(cin>>x)
	{
		for(int i=0; i<x; i++)
		{
			cin>>m>>e>>j;
			
		
		cout<<school(m,e,j)<<endl;
		}
	}
	
	return 0;
}

C++: #include <iostream>
using namespace std;

int main(){
    while(1){
        int n;
        cin >> n;
        if(!n) break;

        for(int i = 0;i < n;i++){
            int pm, pe, pj;
            cin >> pm >> pe >> pj;

            char ans = 'C';
            int ave = (pm + pe + pj) / 3;
            if(pm == 100 || pe == 100 || pj == 100) ans = 'A';
            else if((pm + pe) / 2 >= 90) ans = 'A';
            else if(ave >= 80) ans = 'A';
            else if(ave >= 70) ans = 'B';
            else if(ave >= 50 && (pm >= 80 || pe >= 80)) ans = 'B';

            cout << ans << endl;
        }
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int n;
	while (cin >> n&&n != 0) {
		for (int i = 0; i < n; i++) {
			int e, f, g, a = 0, b = 0, c = 0;
			char l;
			cin >> e >> f >> g;
			if (e == 100 || f == 100 || g == 100)
				a++;
			if ((e + f) / 2 >= 90)
				a++;
			double d = (e + f + g) / 3;
			if (d >= 80)
				a++;
			if (d >= 70)
				b++;
			if (d >= 50 && (e >= 80 || f >= 80))
				b++;
			if (a != 0 )
				cout << 'A' << endl;
			else if (b != 0)
				cout << 'B' << endl;
			else
				cout << 'C' << endl;
		}
	}
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
class state{
public:
  int p,d;
  bool operator<(const state & a)const{
    if (d != a.d)return d > a.d;
    return p < a.p;
  }
};

main(){
  int n;
  while(cin>>n&&n ){
    rep(i,n){
      int m,e,j;
      cin>>m>>e>>j;
      if (m>=100||e>=100||j>=100||(m+e)>=180 ||m+e+j >= 3*80)cout << "A"<<endl;
      else if (m+e+j>= 3*70 || (m+e+j>=50 && (m>=80||e>=80)))cout <<"B"<<endl;
      else cout << "C" << endl;
    }
  }
}

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

int main(){

int N,M,K,R;
double ave=0,S=0,aav=0;
while(1){
cin>>N;if(N==0)break;
for(int i=0;i<N;i++){
cin>>M>>R>>K;
S=M+R+K;ave=S/3;aav=(M+R)/2;
if(aav>=90)printf("A\n");
else if(ave>=80)printf("A\n");
else if(M==100||R==100||K==100)printf("A\n");
else if(ave>=70)printf("B\n");
else if(ave>=50){if(M>=80||R>=80)printf("B\n");}
else printf("C\n");
}
ave=0,S=0,aav=0;
}
return 0;
}

C++: #include <iostream>

int value (int pm, int pe, int pj);
int main()
{
    int N;
    std::cin >> N;
    while (N > 0) {
        for (int i = 0; i < N; i++) {
            int pm, pe, pj;	       
            std::cin >> pm >> pe >> pj;
            if (value (pm, pe, pj) == 1) {
                std::cout << "A" <<std::endl;
                } else if (value (pm, pe, pj) == 2) {
                std::cout << "B" <<std::endl;
                } else {
                std::cout << "C" <<std::endl;
                }
        }
    std::cin >> N;
    }
    return 0;
}

int value(int pm, int pe, int pj)
{
    if (pm == 100 || pe == 100 || pj == 100) {
    return 1;
    } else if (pm + pe >= 180) {
    return 1;
    } else if (pm + pe + pj >= 240) {
    return 1;
    } else if (pm + pe + pj >= 210) {
    return 2; 
    } else if (pm + pe + pj >= 150 && (pm >= 80 || pe >=80) ) {
    return 2;
    }else {
    return 3;
    }
}

C++: #include<iostream>
using namespace std;

int main()
{
	while (true){
		int n;
		cin >> n;
		if (!n) break;
		for (int i = 0; i < n; i++){
			int pm, pe, pj;
			cin >> pm >> pe >> pj;
			if (pm == 100 || pe == 100 || pj == 100 || (pm + pe) / 2 >= 90 || (pm + pe + pj) / 3 >= 80) cout << "A" << endl;
			else if ((pm + pe + pj) / 3 >= 70 || ((pm + pe + pj) / 3 >= 50) && (pm >= 80 || pe >= 80)) cout << "B" << endl;
			else cout << "C" << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#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 EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

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

//v.erase(unique(v.begin(),v.end()),v.end());

string foo(int a,int b,int c){
	if(max(a,max(b,c))==100) return "A";
	if((a+b)/2>=90) return "A";
	if((a+b+c)/3>=80) return "A";
	if((a+b+c)/3>=70) return "B";
	if((a+b+c)/3>=50&&max(a,b)>=80) return "B";
	return "C";
}


int main(){
	int n;
	while(cin>>n,n){
		int a,b,c;
		rep(i,n){
			cin>>a>>b>>c;
			cout<<foo(a,b,c)<<endl;
		}
	}
}