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 <algorithm>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    while(cin >> n && n){

        for(int i = 0; i < n; ++i){
            int pm, pe, pj;
            cin >> pm >> pe >> pj;  // ??°????????±????????????

            char ans = 'C';
            int ave = (pm + pe + pj) / 3;

            if(ave >= 50 && (pm >= 80 || pj >= 80)) ans = 'B';
            if(ave >= 70) ans = 'B';
            if(ave >= 80) ans = 'A';
            if(pm + pe >= 180) ans = 'A';
            if(pm == 100 || pe == 100 || pj == 100) ans = 'A';

            cout << ans << endl;
        }
    }

   return 0;
}

C++: // #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;

#define MP make_pair
#define fastIO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
int INPUT_INT() { int d; cin >> d; return d; } // 入力をpush_back(d)やarray[d]に使う時に1行で書ける

// ------------------- include, typedef, define END. -------------------

double ave(int a, int b, int c){
	return (a + b + c) / 3.0;
}

char solve(int m, int e, int j){
	if (m == 100 || e == 100 || j == 100 || ((m + e) / 2.0) >= 90.0 || ave(m, e, j) >= 80.0)
		return 'A';
	else if (ave(m, e, j) >= 70.0 || (ave(m, e, j) >= 50.0 && (m >= 80 || e >= 80)))
		return 'B';
	else
		return 'C';
}

int main(){
	fastIO;
	int n,m,e,j;
	while (cin >> n, n){
		while (n--){
			cin >> m >> e >> j;
			cout << solve(m,e,j) << endl;
		}
	}
	return 0;
}

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

C++: #include <iostream>
using namespace std;
&#160;
char judge(int pm, int pe, int pj)
{
&#160; &#160; if(pm == 100 || pe == 100 || pj == 100 || pm + pe >= 180 || pm + pe + pj >= 240) return 'A';
&#160; &#160; else if(pm + pe + pj >= 210 || pm + pe + pj >= 150 && (pm >= 80 || pe >= 80)) return 'B';
&#160; &#160; return 'C';
}
&#160;
int main()
{
&#160; &#160; int n, pm, pe, pj;
&#160; &#160; while(cin >> n, n){
&#160; &#160; &#160; &#160; for(int i = 0; i < n; ++i){
&#160; &#160; &#160; &#160; &#160; &#160; cin >> pm >> pe >> pj;
&#160; &#160; &#160; &#160; &#160; &#160; cout << judge(pm,pe,pj) << endl;
&#160; &#160; &#160; &#160; }
&#160; &#160; }
}
&#160;

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==80||pe==80) a[i]='B';
			else a[i]='C';
		}
		for(i=0;i<n;i++) printf("%c\n",a[i]);
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
char hyakuten(int students[][3],int n){
  for(int i=0;i<3;i++){
   if(students[n][i]==100)return 'A';
  }
  if((students[n][0]+students[n][1])/2>=90)return 'A';
  if((students[n][0]+students[n][1]+students[n][2])/3>=80)return 'A';
  if((students[n][0]+students[n][1]+students[n][2])/3>=70)return 'B';
  if((studnets[n][0]+studnets[n][1]+students[n][2])/3>=50&&students[n][0]>=80||students[n][1]>=80)return 'B';
  return 'C';
}


int main(){
  int n;
  while(cin>>n&&n){
    int students[10000][3];
    for(int i=0;i<n;i++){
      for(int j=0;j<3;j++){
        cin>>students[i][j];
      }
    }
    for(int i=0;i<n;i++){
      cout<<hyakuten(i)<<endl;
    }
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
long n,i,pm,pe,pj;
while(cin>>n,n){
for(i=0;i<n;i++){
cin>>pm>>pe>>pj;
if(pm==100||pe==100||pj==100){cout<<"A"<<endl;continue;}
if(pm+pe>=180){cout<<"A"<<endl;continue;}
if(pm+pe+pj>=240){cout<<"A"<<endl;continue;}
if(pm+pe+pj>=210){cout<<"B"<<endl;continue;}
if(pm+pe+pj>=150&&(pm>=80||pe>=80)){cout<<"B"<<endl;continue;}
cout<<"C"<<endl;
}
}
return 0;
}

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

int main(){
  int n;
  while(true){
    cin>>n;
    if(n==0){
      break;
    }
    int m[n],e[n],j[n],me[n],total[n];
    for(int i=0;i<n;i++){
      cin>>m[i]>>e[i]>>j[i];
      me[i]=m[i]+e[i];
      total[i]=m[i]+e[i]+j[i];
    }
    for(int k=0;k<n;k++){
      if(m[k]==100||e[k]==100||j[k]==100||me[k]>=180||total[k]>=240){
	cout<<"A"<<endl;
      }else if(total[k]>=210){
	cout<<"B"<<endl;
      }else if(total[k]>=150&&m[k]>=80){
	cout<<"B"<<endl;
      }else if(total[k]>=150&&e[k]>=80){
	cout<<"B"<<endl;
      }else{
	cout<<"C"<<endl;
      }
    }
  }

    return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
char hyakuten(int students[][3],int n){
  for(int i=0;i<3;i++){
   if(students[n][i]==100)return 'A';
  }
  if((students[n][0]+students[n][1])/2>=90)return 'A';
  if((students[n][0]+students[n][1]+students[n][2])/3>=80)return 'A';
  if((students[n][0]+students[n][1]+students[n][2])/3>=70)return 'B';
  if((students[n][0]+students[n][1]+students[n][2])/3>=50&&students[n][0]>=80||students[n][1]>=80)return 'B';
  return 'C';
}


int main(){
  int n;
  while(cin>>n&&n){
    int students[10000][3];
    for(int i=0;i<n;i++){
      for(int j=0;j<3;j++){
        cin>>students[i][j];
      }
    }
    for(int i=0;i<n;i++){
      cout<<hyakuten(i)<<endl;
    }
  }
  return 0;
}

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

using namespace std;

int main()
{
	int n;
	while(cin >> n && n)
	{
		while(n--)
		{
			int a,b,c;
			cin >> a >> b >> c;
			int ava=(a+b+c)/3;

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