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>

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

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 >= 80 || pe >= 80) cout << "B" << endl;
			else cout << "C" << endl;
		}
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define REP(i,n) for(long long i=0;i<n;++i)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
using namespace std;
using point = pair< int,int >;
using ll = long long;

int main(){
    int n;
    int m, e, j;
    bool hund;
    while (~scanf("%d", &n)) {
        REP(i, n) {
            hund = false;
            scanf("%d%d%d", &m, &e, &j);
            if (m == 100 || e == 100 || j == 100) hund = true;
            if (hund || (m + e) / 2 >= 90 || (m + e + j) / 3 >= 80) {
                puts("A");
            } else if ((m + e + j) / 3 >= 70 || (m + e + j) / 3 >= 50 && (m >= 80 || e >= 80)) {
                puts("B");
            } else {
                puts("C");
            }
        }
    }

    return 0;
}