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>
using namespace std;
int main(){
	int n, m, e, j;
	cin >> n;
	while (n != 0){//0??§??????
		for (int i = 0; i < n; i++){
			cin >> m >> e >> j;//?????????????????°????????±????????????
			if (m == 100 || e == 100 || j == 100) cout << "A" << endl;
			else if ((m + e) / 2 >= 90)cout << "A" << endl;
			else if ((m + e + j) / 3 >= 80) cout << "A" << endl;
			else if ((m + e + j) / 3 >= 70 && (m + e + j)/3 < 80) cout << "B" << endl;
			else if ((m + e + j) / 3 >= 50 && m >= 80 || e >= 80)cout << "B" << endl;
			else cout << "C" << endl;
		}
		cin >> n;
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	int n;
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			int m, e, j;
			cin >> m >> e >> j;

			if (m == 100 || e == 100 || j == 100 || (m + e) / 2 >= 90 || (m + e + j) / 3 >= 80)cout << 'A' << endl;
			else if ((m + e + j) / 3 >= 70 || ((m + e + j) / 3 >= 50) && ((m >= 80) || (e >= 80)))cout << 'B' << endl;
			else cout << 'C' << endl;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include <cstring>
#include<map>
#include<string>
#include<stack>
#include <sstream>
#include<vector>
using namespace std;


int main(){
	int n;
	while(cin>>n)
	{
		if(n==0)break;
		while(n--)
		{
			int ei,suu,koku;
			cin>>suu>>ei>>koku;
			if( suu==100 || ei==100 || koku==100 ) puts("A");
			else if( (suu+ei)/2 >= 90 ) puts("A");
			else if( (suu+ei+koku)/3 >=80 ) puts("A");
			else if( (suu+ei+koku)/3 >=70 ) puts("B");
			else if( (suu+ei+koku)/3 >=50  && (suu==80 || ei==80 ) ) puts("B");
			else puts("C");
		}
	}
	return 0;
}

C++: 
#include <iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<sstream>
using namespace std;
int main(){
    int n,i,a[10000],b[10000],c[10000],ans1=0,ans2=0;
    while(cin>>n){
        if(n==0)break;
        for(i=0;i<n;i++){
            cin>>a[i]>>b[i]>>c[i];
            ans1=(a[i]+b[i]+c[i])/3;
            ans2=(a[i]+b[i])/2;
            if(a[i]==100||b[i]==100||c[i]==100||ans1>=80||ans2>=90){
                cout<<"A"<<endl;
            }
            else if(ans1>=70||ans1>=50&&a[i]>=80||ans1>=50&&b[i]>=80){
                cout<<"B"<<endl;
            }
            else{
                cout<<"C"<<endl;
            }
        }
        
    }
     return 0;
}

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

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

C++: 
#include<iostream>
#define rep(i,n) for(i = 0;i < n;i++)
using namespace std;

int m,e,j;

int main(){
	int n,i;
	while( cin >> n ){
		if( n == 0 )
			break;
		rep(i,n){
			cin >> m >> e >> j;
			//上から順に振り分け
			if( max(m,max(e,j)) == 100 || (m+e) >= 180 || (m+e+j) >= 240 ){
				cout << "A" << endl;
			}
			else if( m+e+j >= 210 || ( (m >= 80 || e >= 80) && m+e+j >= 150 ) ){
				cout << "B" << endl;
			}
			else
				cout << "C" << endl;
		}
	}
	return 0;
}

C++: #include <stdio.h>
#include <stdbool.h>

int main(void)
{
    int n;
    int pm, pe, pj;
    int i;
    int sum;
    while (true) {
        scanf("%d", &n);
        if (n == 0) {
            break;
        } else {
            for (i = 0; i < n; ++i) {
                scanf("%d %d %d", &pm, &pe, &pj);
                sum = pm + pe + pj;
                if (pm == 100 || pe == 100 || pj == 100) {
                    printf("A\n");
                } else if (pm + pe >= 180) {
                    printf("A\n");
                } else if (sum >= 240) {
                    printf("A\n");
                } else if (sum >= 210) {
                    if (pm >= 80 || pe >= 80) {
                        printf("A\n");
                    } else {
                        printf("B\n");
                    }
                } else if (sum >= 150) {
                    if (pm >= 80 || pe >= 80) {
                        printf("B\n");
                    } else {
                        printf("C\n");
                    }
                } else {
                    printf("C\n");
                }
            }
        }
    }
    return 0;
}

C++: #include<iostream>

char *c;
int n,pm,pe,pj;

char solve(int m, int e, int j){
	char ans='C';
	if(m==100 || e==100 || j==100 || m+e>=180 || m+e+j>=240)
		ans = 'A';
	else if(m+e+j>=210 || (m+e+j>=150 && (m>=80 || e>=80)))
		ans = 'B';
	return ans;
}

int main(){
	while(true){
		std::cin >> n;
		if(!n)
			return 0;
		c = new char[n];
		for(int i=0; i<n; i++){
			std::cin >> pm >> pe >> pj;
			c[i] = solve(pm, pe, pj);
		}
		for(int i=0; i<n; i++)
			std::cout << c[i] << std::endl;
		delete[] c;
	}
	return 0;
}

C++: #include<stdio.h>
int main()
{
	int n,a,b,c,d,e;
	while(scanf("%d",&n),n)
	{
		while(n--)
		{
			scanf("%d%d%d",&a,&b,&c);
			d=(a+b+c)/3;
			e=(a+b)/2;
			if(a>99||b>99||c>99||e>89||d>79)puts("A");
			else if(d>69||d>49&&(a>79||b>79))puts("B");
			else puts("C");
		}
	}
	return 0;
}

C++: #include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int n;
	while(scanf("%d",&n),n) {
		for(int i=0;i<n;i++) {
			int pm,pe,pj;
			scanf("%d %d %d",&pm,&pe,&pj);
			if(max(pm,max(pe,pj))==100||(pm+pe)>=180||(pm+pe+pj)>=240) {
				printf("A\n");
			}else if((pm+pe+pj)>=210||((pm+pe+pj)>=150&&max(pm,pe)>=80)) {
				printf("B\n");
			}else {
				printf("C\n");
			}
		}
	}
}

C++: #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;
	}
}