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<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int a[1000],n,p,q,r;
  while(cin>>n&&n){
    for(i=0;i<n;i++){
      cin>>p>>q>>r;
      if(p==100||q==100||r==100)
	a[i]=0;
      else if(p+q>179)
	a[i]=0;
      else if(p+q+r>239)
	a[i]=0;
      else if(p+q+r>209)
	a[i]=1;
      else if(p+q+r>149&&(p>79||q>79))
	a[i]=1;
      else
	a[i]=2;
    }
    for(i=0;i<n;i++)
      cout<<(char)('A'+a[i])<<endl;
  }
  return 0;
}

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

int main(){
	int n;
	int pm, pe, pj;
	while(cin >> n, n){
		for(int i=0; i < n; i++){
			cin >> pm >> pe >> pj;

			if(pm == 100 || pe == 100 || pj == 100) cout << 'A' << endl;
			else if(90 <= (pm + pe) / 2) cout << 'A' << endl;
			else if(80 <= (pm + pe + pj) / 3) cout << 'A' << endl;
			else if(70 <= (pm + pe + pj) / 3) cout << 'B' << endl;
			else if(50 <= (pm + pe + pj) / 3 && (80 <= pm || 80 <= pe)) cout << 'B' << endl;
			else cout << 'C' << endl;
		}
	}
}

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

int main()
{
	int n;

	cin >> n;

	while (n > 0) {
		for (int i = 0; i < n; i++) {
			int pm, pe, pj;

			cin >> pm >> pe >> pj;

			if(pm == 100 || pe == 100 || pj == 100 || pm + pe >= 180 || pm + pe + pj >= 240)
				cout << "A" << endl;
			else if (pm + pe + pj >= 210 || (pm + pe + pj >= 150 && (pm >= 80 || pe >= 80)))
				cout << "B" << endl;
			else
				cout << "C" << endl;
		}
		
		cin >> n;
	}
	
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
    int eng,ma,jp,n;
    char judge[10000];
    while(1){
        cin>>n;
        if(n==0){
            break;
        }
        for(int i=0;i<n;i++){
            cin>>ma>>eng>>jp;
            if((ma==100 || eng==100 || jp==100)||((ma+eng)/2>=90)||((ma+eng+jp)/3>=80)){
                judge[i]='A';
            }
            else if(((ma+eng+jp)/3>=70)||((ma+eng+jp)/3>=50&&(eng>=80 || ma>=80))){
                judge[i]='B';
            }
            else {
                judge[i]='C';
            }
        }
        for(int i=0;i<n;i++){
            cout<<judge[i]<<endl;
        }
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,n;
	while(cin>>n,n){
		for(int i=0;i<n;i++){
			cin>>a>>b>>c;
			if(a==100||b==100||c==100||a+b>=180||a+b+c>=240)cout<<'A'<<endl;
			else if(a+b+c>=210||(a+b+c>=150&&(a>=80||b>=80)))cout<<'B'<<endl;
			else cout<<'C'<<endl;
		}
	}
}

C++: #include<stdio.h>
#include <iostream>
using namespace std;
int main(void){

	int n,i,j,pm,pe,pj,a,d=-1,c=-1,max=-1;
	scanf("%d",&n);
	while ( n > 0){
		for (i = 0; i < n; i++){
			scanf("%d %d %d",&pm,&pe,&pj);
			if ((pm == 100 || pe == 100 || pj == 100) || ((pm + pe) / 2>=90||(pe+pj+pm)/3>=80)){

				printf("A\n");
			}
			else if ((pe + pj + pm) / 3 >= 70 || ((pm + pj + pe) / 3 >= 50 && (pe >= 80 || pm >= 80))){
				printf("B\n");
			}
			else printf("C\n");
		}
			scanf("%d", &n);
	}
}

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

C++: #define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <sstream>
#include <list>
#include <map>

#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define repp(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define Sort(x) sort(x.begin(),x.end());
#define ll long long 
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi <vector<vector<vector<int>>> 
#define vc vector<char> 
#define vvc vector<vector<char>>
#define vvvc vector<vector<vector<char>>> 
#define INF 2000000000

using namespace std;

int main() {
	while (1) {
		int n;
		cin >> n;
		if (n == 0)break;

		rep(i, 0, n) {
			int a, b, c;
			cin >> a >> b >> c;

			if (a == 100 || b == 100 || c == 100) {
				cout << "A" << endl;
			}
			else if ((a + b) / 2.0 >= 90) cout << "A" << endl;
			else if ((a + b + c) / 3.0 >= 80)cout << "A" << endl;
			else if ((a + b + c) / 3.0 >= 70) cout << "B" << endl;
			else if ((a + b + c) / 3.0 >= 50 && (a >= 80 || b >= 80))cout << "B" << endl;
			else cout << "C" << endl;
		}
	}

	

	


	return 0;
}

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

char g(int m,int e,int j){
	if(m==100||e==100||j==100) return 'A';
	if(m+e>=180) return 'A';
	if(m+e+j>=240) return 'A';
	if(m+e+j>=210) return 'B';
	if(m+e+j>=150&&(m>=80||e>=80)) return 'B';
	return 'C';
	
}
int main(){
	int n;
	while(cin >> n && n){
		for(int i = 0 ; i < n ; i++){
			int m,e,j;
			cin >> m >> e >> j;
			cout << g(m,e,j) << endl;
		}
	}
}

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

int main(){
	
	int n;
	while(cin>>n){
		if(n!=0){
	while(n>0){
		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+pe+pj)/3>=50&&pm>=80||pe>=80))
			cout<<"B"<<endl;
		else
			cout<<"C"<<endl;
		n--;
	}
	}
		else
			break;
	}

	

}

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