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 <cstdio>
#include <algorithm>
#include <array>
#include <vector>

using namespace std;

int main() {

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

C++: #include <iostream>
using namespace std;
int main(){
	int n,pj,pm,pe;
	while(1){
		cin>>n;
		if(n==0) break;
		for(int i<=1;i<=n;i++){
			cin>>pm>>pe>>pj;
			if(pm==100||pj==100||pe==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++: #include <stdio.h>

char divide(int math, int english, int japanese);
char class;

int main(void)
{
    int dataset;
    int math, english, japanese;

    while (1){
        scanf("%d", &dataset);
        if (dataset == 0){
            break;
        } else {
            while (dataset--){
                scanf("%d %d %d", &math, &english, &japanese);
                class = divide(math, english, japanese);
                printf("%c\n", class);
            }
        }
    }

    return 0;
}

char divide(int math, int english, int japanese)
{
    int sum = math + english + japanese;

    if (math == 100 || english == 100 || japanese == 100){
        class = 'A';
    } else if (math + english >= 90 * 2){
        class = 'A';
    } else if (sum >= 80 * 3){
        class = 'A';
    } else if (sum >= 70 * 3){
        class = 'B';
    } else if (sum >= 50 * 3 && (math >= 80 || english >= 80)){
        class = 'B';
    } else {
        class = 'C';
    }

    return class;
}

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

int main(){
	int n = 1, pm, pe, pj;

	while(n != 0){
		cin >> n;
		for(int i = 0; i < n; i++){
			cin >> pm >> pe >> pj;
			if((pm+pe+pj)/3 >= 90) cout << "A" << endl;
			else if((pm+pe)/2 >= 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>
using namespace std;

int main()
{
  while(true){
    int n;
    cin >> n;
    if( n == 0 ) break;
    for(int i = 0; i < n; ++i ){
      int pm,pe,pj;
      double meav;
      double av;
      char rank = 'C';
      cin >> pm >> pe >> pj; // math , english, japanese
      meav = ((double)(pm+pe))/2.;
      av = ((double)(pm+pe+pj))/3.;
      if( pm == 100 || pe == 100 || pj == 100 ){
	rank = min( 'A' , rank );
      }
      if( meav >= 90.0 ){
	rank = min( 'A' , rank );
      }
      if( av >= 80.0 ){
	rank = min( 'A', rank );
      }
      if( av >= 70.0 ){
	rank = min( 'B', rank );
      }
      if( av >= 50.0 && ( pm >= 80 || pe >= 80 ) ){
	rank = min( 'B', rank );
      }
      
      cout << rank << endl;
    }
  }
  return 0;
}

C++: // 2012/07/09 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		for(int i=0; i<n; i++){
			int pm, pe, pj;
			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>
using namespace std;

int main() {
	int n,c;
	double h,pm,pe,pj;
	while(cin >> n && n!=0) {
	for (;n>0;n--) {
		c=2;
		cin >> pm >> pe >> pj;
		h=(pm+pe+pj)/3;
		if ((h>=50 && (pm>=80 || pe>=80)) || h>70) c=1;
		if (h>=80 || ((pm+pe)/2>=90) || pm==100 || pe==100 || pj==100) c=0;
		cout << (char)('A'+c) << endl;
	}
}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
class data{
public:
    int pm,pe,pj,rank;
    double me(){return (double)(pm+pe)/2;};
    double ave(){return (double)(pm+pe+pj)/3;}
    int maxi(){return max(max(pm,pe),pj);};
};
int main(){
    int n;
    while(cin>>n){
        if(!n)return 0;
        vector<data>v(n+1);
        v.clear();
        rep(i,n){
            cin>>v[i].pm>>v[i].pe>>v[i].pj;
            if(v[i].me()>=90||v[i].ave()>=80||v[i].maxi()==100){
                v[i].rank=3;
            }else if(v[i].ave()>=70||(v[i].ave()>=50&&(v[i].pe>=80||v[i].pm>=80)))
                v[i].rank=2;
            else
                v[i].rank=1;
            switch (v[i].rank) {
                case 1:
                    cout<<"C"<<endl;
                    break;
                case 2:
                    cout<<"B"<<endl;
                    break;
                default:
                    cout<<"A"<<endl;
                    break;
            }
        }
    }
}

C++: #include <iostream>

using namespace std;

char judge(int a, int b, int c) {
	if (a == 100 || b == 100 || c == 100) return 'A';
	if ((a + b) / 2.0 >= 90) return 'A';

	int p = a + b + c;
	double aver = p / 3.0;

	if (aver >= 80) return 'A';
	if (aver >= 70) return 'B';
	if (aver >= 50 && (a >= 80 || b >= 80)) return 'B';

	return 'C';
}

int main() {
	int n;

	while (cin >> n, n) {
		for (int i = 0; i < n; ++i) {
			int a, b, c; cin >> a >> b >> c;
			cout << judge(a, b, c) << endl;
		}
	}
}