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>

int main()
{
int n,pm,pe,pj;
    while (true){
        std::cin >> n;
        if (n == 0){
            break;
}       for (int i = 0;i < n;i++){
            std::cin >> pm >> pe >> pj;
            if (pm == 100 || pe == 100 || pj == 100 || pm + pe >= 180 || pm + pe + pj >= 240){
                std::cout << "A" << std::endl;
}           else if (pm + pe + pj >= 210 || (pm + pe + pj >= 150 && (pm - 80) * (pe - 80) >= 0 )){
                std::cout << "B" << std::endl;
}           else{
                std::cout << "C" << std::endl;
}
}
}
    return 0;
}

C++: #include<stdio.h>

int main(void)
{
	int n, i, pm, pe, pj;

	while (1)
	{
		scanf("%d", &n);
		if (n == 0)break;
		for (i = 0;i < n;i++)
		{
			scanf("%d %d %d", &pm, &pe, &pj);
			if (pm == 100 || pe == 100 || pj == 100)
			{
				printf("A\n");
			}
			else if ((pm + pe) / 2 >= 90)
			{
				printf("A\n");
			}
			else if ((pm + pe + pj) / 3 >= 80)
			{
				printf("A\n");
			}
			else if ((pm + pe + pj) / 3 >= 70)
			{
				printf("B\n");
			}
			else if ((pm + pe + pj) / 3 >= 50)
			{
				if (pm >= 80 || pe >= 80)
				{
					printf("B\n");
				}
				else
				{
					printf("C\n");
				}
			}
			else
			{
				printf("C\n");
			}
		}

	}
	return 0;
}

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

int main()
{

	while(true){

		int n;
		int m=0,e=0,j=0;

		cin >> n;

		if(n==0)
			break;

		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)
				cout << 'B' << endl;
		
			else if((m + e + j)/3 >= 50 && (m >=80 || e >= 80))
				cout << 'B' << endl;
		
			else
				cout << 'C' << endl;
		}

	}

	return 0;
}

C++: using namespace std;
#include <iostream>
#include <string>
#include <set>
#include <functional>
#include <vector>
#include <algorithm>
#include <stdio.h>
int main()
{
	int n;
	while(cin>>n&&n){
		int pm,pe,pj;
		while(n--){
			char ans='C';
			cin>>pm>>pe>>pj;
			if(pm==100||pe==100||pj==100||
				pm+pe>=180||pm+pe+pj>=240)ans='A';
			else if(pm+pe+pj>=210||
				(pm+pe+pj>=150&&(pm>=80||pe>=80)))ans='B';
			cout<<ans<<endl;
		}

	}
    return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int dx[8] = {-1, 0, 1, 0, -1, -1, 1, 1};
int dy[8] = {0, -1, 0, 1, -1, 1, -1, 1};

int main() {
  int n;

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

    REP(i, n) {
      int pm = 0, pe = 0, pj = 0;
      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; 
    }
  }
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef vector<xy_t> polygon;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 29;
const double EPS = 1e-10;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
#define repD(i, n) for(int i = n; i >= 0; i--)

void judge(int a, int b, int c){
	int ave = (a + b + c) / 3;
	if(a == 100 || b == 100 || c == 100 || (a + b) / 2 >= 90 || ave >= 80) {
		cout << 'A' << endl;
	}else if(ave >= 70 || (ave >= 50 && max(a, b) >= 80)){
		cout << 'B' << endl;
	}else{
		cout << 'C' << endl;
	}
}

int main(){
	int n;
	int pm, pe, pj;
	while(cin >> n && n){
		rep(i, n){
			cin >> pm >> pe >> pj;
			judge(pm, pe, pj);
		}
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>

char judge_grade(int pm, int pe, int pj)
{
    if(std::max({pm, pe, pj}) == 100 || (pm + pe) / 2 >= 90 || (pm + pe + pj) / 3 >= 80) {
        return 'A';
    } else if((pm + pe + pj) / 3 >= 70 || ((pm + pe + pj) / 3 >= 50 && std::max(pm, pe) >= 80)) {
        return 'B';
    } else {
        return 'C';
    }
}

int main()
{
    int num;
    
    while(num != 0) {

        std::cin >> num;

        int pm, pe, pj;

        for(int i = 0; i < num; i++) {
            std::cin >> pm >> pe >> pj;
            std::cout << judge_grade(pm, pe, pj) << std::endl;
        }

    }

    return 0;
}

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

char get(int a,int b,int c){
	if(a==100||b==100||c==100 || a+b>=180 || a+b+c >= 240)return 'A';
	if(a+b+c>=210 || (a+b+c>=150&&(a>=80||b>=80)))return 'B';
	return 'C';
}
int main(){
	int n;
	while(cin >> n , n){
		rep(i,n){
			int a,b,c;
			cin >> a >> b >> c;
			cout << get(a,b,c) << endl;
		}
	}
}