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 <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;


int main(){
	int n;
	
	while(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)puts("A");
			else if(pe+pm>=180)puts("A");
			else if(pe+pm+pj>=240)puts("A");
			else if(pe+pm+pj>=210)puts("B");
			else if(pe+pm+pj>=150 && (pe>=80 || pm>=80))puts("B");
			else puts("C");
		}
	}
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int n,pm,pe,pj,s,i;
	char a[10001];
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		for(i=0;i<n;i++){
			scanf("%d%d%d",&pm,&pe,&pj);
			s=(pm+pe+pj)/3;
			if(pm==100||pe==100||pj==100) a[i]='A';
			else if((pm+pe)/2>=90) a[i]='A';
			else if(s>=80) a[i]='A';
			else if(s>=70) a[i]='B';
			else if(s>=50&&(pm+pe)/2>=80) a[i]='B';
			else a[i]='C';
		}
		for(i=0;i<n;i++) printf("%c\n",a[i]);
	}
	return 0;
}

C++: #include <iostream>

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

int main()
{
    while(1){
        int n;
        std::cin >> n;
        if(n==0){
            return 0;
        }
        for (int i=0; i<n; i++) {
            int pm,pe,pj;
            std::cin >> pm >>pe >>pj;
            std::cout << DividingStudent(pm, pe, pj) << std::endl;
        }
    }
}

C++: /*
 * src.cpp
 *
 *  Created on: 2016/08/04
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

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

const int MAX_N=1e4;

int n;
int p[3];

char out[MAX_N+5];

int main(){
	do{
		cin>>n;
		if (n){
			REP(i,n){
				int ave=0;
				bool f=false;
				REP(j,3){
					cin>>p[j];
					ave+=p[j];
					if (p[j]==100){
						f=true;
					}
				}
				if (f){
					out[i]='A';
				}else if (p[0]+p[1]>=180){
					out[i]='A';
				}else if (ave>=80*3){
					out[i]='A';
				}else if (ave>=70*3){
					out[i]='B';
				}else if (ave>=50*3 && (p[0]>=80 || p[1]>=80)){
					out[i]='B';
				}else{
					out[i]='C';
				}
			}
			REP(i,n){
				cout<<out[i]<<endl;
			}
		}
	}while (n);
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        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;
        }
    }
}

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;
			cin >> pm >> pe >> pj;
			if(pm,pe,pj == 100 || (pm + pe) / 2 >= 90 || (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,pe >= 80)cout << "B" << endl;
			else cout << "C" << endl;
		}
	}
}

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

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

int n;

const char mes[3] = {'A', 'B', 'C'};

void solve() {
  rep(i,n) {
    int pm, pe, pj; cin>>pm>>pe>>pj;
    double avg = (pm+pe+pj)/3.0;
    int res;
    if (pm == 100 || pe == 100 || pj == 100) {
      res = 0;
    } else if ((pm+pe)/2.0 >= 90.0) {
      res = 0;
    } else if (avg >= 80.0) {
      res = 0;
    } else if (avg >= 70.0) {
      res = 1;
    } else if (avg >= 50.0 && (pm >= 80 || pe >= 80)) {
      res = 1;
    } else {
      res = 2;
    }
    cout<<mes[res]<<endl;
  }
}

int main (int argc, char const* argv[]) {
  while (cin>>n, n) {
    solve();
  }
  return 0;
}

C++: /*
	0218:Dividing Students
*/
#include	<iostream>

using namespace std;

int main(void) {
	while(1) {
		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( ( (double)pm + pe ) / 2 >= 90.0 ) { cout << 'A' << endl; }
			else if( ( (double)pm + pe + pj ) / 3 >= 80.0 ) { cout << 'A' << endl; }
			else if( ( (double)pm + pe + pj ) / 3 >= 70.0 ) { cout << 'B' << endl; }
			else if( ( (double)pm + pe + pj ) / 3 >= 50.0 && ( pm >= 80 || pe >= 80 ) ) { cout << 'B' << endl; }
			else { cout << 'C' << endl; }
		}
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int n,a,b,c;
char solve(){
  if(a==100||b==100||c==100)return 'A';
  if(a+b>=180)return 'A';
  if(a+b+c>=240)return 'A';
  if(a+b+c>=210)return 'B';
  if(a+b+c>=150&&(a>=80||b>=80))return 'B';
  return 'C';

}
int main(){
  while(cin>>n&&n){
    for(int i=0;i<n;i++){
      cin>>a>>b>>c;
      cout<<solve()<<endl;
    }
  }
  return 0;
}

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

using namespace std;

#define MAX 300000

int n, pm, pe, pj;

int main() {
	while (1) {
		scanf("%d", &n);
		if (n == 0)
			return 0;

		while(n-- > 0) {
			scanf("%d %d %d", &pm, &pe, &pj);
			if(max(pm, max(pe, pj)) == 100 || pm + pe >= 180 || pm + pe + pj >= 240)
				puts("A");
			else if(pm + pe + pj >= 210 || pm + pe + pj >= 150 && max(pm, pe) >= 80)
				puts("B");
			else
				puts("C");
		}
	}
}

C++: #include <cstdio>

int main(void) {
	while(true) {
		int n;
		scanf("%d", &n);
		if(n == 0)
			break;
		for(int i = 0; i < n; i++) {
			int m, e, j;
			char level = 'C';
			scanf("%d%d%d", &m, &e, &j);
			if(m == 100 || e == 100 || j == 100)
				level = 'A';
			if((m + e) / 2 >= 90)
				level = 'A';
			if((m + e + j) / 3 >= 80)
				level = 'A';
			if((m + e + j) / 3 >= 70 && level == 'C')
				level = 'B';
			if((m + e + j) / 3 >= 50 && level == 'C' && (m >= 80 || e >= 80))
				level = 'B';
			printf("%c\n", level);
		}
	}
	return 0;
}