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, a, b, c;

    while( cin >> n )
    {
        if( n == 0 )
            break;
        
        for( int i = 0; i < n; i++ )
        {
            cin >> a >> b >> c;
            if( ( a == 100 || b == 100 || c == 100 ) || ( a + b ) / 2 >= 90 || ( a + b + c ) / 3 >= 80 )
                cout << 'A' << endl;
            else if( ( a + b + c ) / 3 >= 70 || ( ( a + b + c ) / 3 >= 50 ) && ( a >= 80 || b >= 80 ) )
                cout << 'B' << endl;
            else
                cout << 'C' << endl;
        }
    }
    return 0;
}

C++: #include <bits/stdc++.h>

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("%lld", &x); return (x); }

int main()
{
	int point[3];
	int n;
	int ave;
	int me_ave;
	bool has100point;

	while( true )
	{
		n = in();
		if( n == 0 )break;
		for(int i = 0; i < n; i++)
		{
			ave = me_ave = 0;
			has100point = false;
			for(int j = 0; j < 3; j++)
			{
				point[j] = in();
				if( point[j] == 100 )has100point = true;
			}
			ave = (point[0] + point[1] + point[2]) / 3;
			me_ave = (point[0] + point[1]) / 2;
			if( has100point || me_ave >= 90 || ave >= 80 )
			{
				puts("A");
			}
			else if( ave >= 70 || (ave >= 50 && (point[0] >= 80 || point[1] >= 80)) )
			{
				puts("B");
			}
			else
			{
				puts("C");
			}
		}
	}
	return (0);
}

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

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

int main(){
	int n,m,e,j;
	while( cin >> n , n ){
		for(int i=0 ; i<n ; ++i ){
			cin >> m >> e >> j;
			cout << solve(m,e,j) << endl;
		}
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#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 <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-8;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		while (n--)
		{
			int m, e, j;
			scanf("%d%d%d", &m, &e, &j);
			int ave = (m + e + j) / 3;
			int r = 0;
			if (m == 100 || e == 100 || j == 100
				|| (m + e) / 2 >= 90
				|| ave >= 80)
				r = 2;
			if (ave >= 70)
				++r;
			if (ave >= 50 && (m >= 80 || e >= 80))
				++r;

			printf("%c\n", r == 0 ? 'C' : r == 1 ? 'B' : 'A');
		}
	}

	return 0;
}

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

#define full (m == 100 || e == 100 || j == 100)
#define avg(n) (m + e + j >= n)
#define me80 (m >= 80 || e >= 80)

int main() {
	int n, m, e, j;
	while (1) {
		cin >> n; if (n == 0)break;
		for (int i = 0; i < n; i++) {
			cin >> m >> e >> j;
			if (full || m + e >= 180 || avg(240)) cout << "A" << endl;
			else if (avg(210) || (avg(150) && me80)) 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;
			if(s>=80||e>=90||a==100||b==100||c==100)cout<<'A'<<endl;
			else if(s>=70||(s>=50&&(a>=80||b>=80)))cout<<'B'<<endl;
			else cout<<'C'<<endl;
		}
	}
}

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

#define full (m == 100 || e == 100 || j == 100)
#define avg(n) (m + e + j >= n)
#define me80 (m >= 80 || e >= 80)

int main() {
	int n, m, e, j;
	while (1) {
		cin >> n; if (n == 0) break;
		for (int i = 0; i < n; i++) {
			cin >> m >> e >> j;
			if (full || m + e >= 180 || avg(240)) cout << "A" << endl;
			else if (avg(210) || (avg(150) && me80)) cout << "B" << endl;
			else cout << "C" << endl;
		}
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

char divide(int m, int e, int j) {
    if (m == 100 || e == 100 || j == 100) return 'A';
    if ( (m+e)/2 >= 90 ) return 'A';
    if ( (m+e+j)/3 >= 80 ) return 'A';
    if ( (m+e+j)/3 >= 70 ) return 'B';
    if ( (m+e+j)/3 >= 50 && (m >= 80 || e >= 80) ) return 'B';
    return 'C';
}

int main() {
    int n;
    while (cin >> n, n) {
        while (n--) {
            int pm, pe, pj;
            cin >> pm >> pe >> pj;
            cout << divide(pm, pe, pj) << endl;
        }
    }
    return 0;
}

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

int main(void)
{
    int n;
    int pm, pe, pj;
    int ave;
    while (true) {
        scanf("%d", &n);
        if (n == 0) {
            break;
        } else {
            for (int i = 0; i < n; ++i) {
                scanf("%d %d %d", &pm, &pe, &pj);
                ave = (pm + pe + pj) / 3;
                if (pm == 100 || pe == 100 || pj == 100) {
                    printf("A\n");
                } else if ((pm + pe) / 2 >= 90) {
                    printf("A\n");
                } else if (ave >= 80) {
                    printf("A\n");
                } else if (ave >= 70) {
                    printf("B\n");
                } else if (ave >= 50 && (pm >= 80 || pe >= 80)) {
                    printf("B\n");
                } else {
                    printf("C\n");
                }
            }
        }
    }
    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) >= 180){
        return 'A';
    } else if ((pm+pe+pj) >= 240){
        return 'A';
    } else if ((pm+pe+pj) >= 210){
        return 'B';
    } else if ((pm+pe+pj) >= 150 && (pm>=80 || pe>=80)) {
        return 'B';
    } else {
        return 'C';
    }
}

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