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<stdio.h>
int main(void)
{
	int n,a,b,c,i,x,y;
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d %d %d",&a,&b,&c);
			x=0;  y=0;
			if(a==100 || b==100 || c==100)  x=1;
			else if((a+b)/2>=90)  x=1;
			else if((a+b+c)/3>=80)  x=1;
			else{
				if((a+b+c)/3>=70)  y++;
				if((a+b+c)/3>=50 && (a>=80 || b>=80))  y++;
			}
			if(x==1)  printf("A\n");
			else if(y==2)  printf("A\n"); 
			else if(y==1)  printf("B\n");
			else printf("C\n");
		}
		scanf("%d",&n);
	}
	return 0;
}

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

int main(){
  struct test{
    int Math;
    int English;
    int Japanese;
  };

  int n;
  double total;
  test student;

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

    for(int i=0;i<n;i++){
      char rank='A';
      while(1){
	cin >> student.Math >> student.English >> student.Japanese;
	if(student.Math==100||student.English==100||student.Japanese==100)break;
	total=student.Math+student.English;
	total=total/2;
	if(total>=90)break;
	total=student.Math+student.English+student.Japanese;
	total=total/3;
	if(total>=80)break;
	
	rank='B';
	if(total>=70){
	  break;
	}
	if(total>=50&&(student.Math>=80||student.English>=80))break;
	
	rank='C';
	if(1)break;
      }
      cout << rank << endl;
    }
  }
  return 0;
}

C++: #include <stdio.h>
int pa(void)
{
    printf("A\n");
}

int pb(void)
{
    printf("B\n");
}

int pc(void)
{
    printf("C\n");
}

int main(void)
{
    int n, i,sum, pm[10000], pj[10000], pe[10000];
    while(1) {
	scanf("%d", &n);
	if (n == 0) {
	    break;
	}
	sum = pm[i] + pe[i] + pj[i];
	for (i = 0; i < n; i++) {
	    scanf("%d %d %d", &pm[i], &pj[i], &pe[i]);
	    sum = pm[i] + pe[i] + pj[i];
	    if (pm[i] == 100 || pj[i] == 100 || pe[i] == 100) {
		pa();
	    } else if (pm[i] + pe[i] >= 180) {
		pa();
	    } else if (sum >= 240) {
		pa();
	    } else if (sum >= 210) {
		pb();
	    } else if (sum >= 150 && (pm[i] >= 80 || pe[i] >= 80)) {
		pb();
	    } else {
		pc();
	    }
	}
    }
    return 0;
}

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

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0218

int main() {
	int n;
	while (cin >> n) {
		for (int i = 0; i < n; i++) {
			int m, e, j;
			cin >> m >> e >> j;
			int avg = (m + e + j) / 3;
			if (m == 100 || e == 100 || j == 100 || (m + e) / 2 > 90 || avg > 80) {
				cout << "A" << endl;
				continue;
			}
			if (avg > 70 || (avg > 50 && (m >= 80 || e >= 80))) {
				if (avg > 50 && (m >= 80 || e >= 80)) cout << "A";
				else cout << "B";
				cout << endl;
				continue;
			}
			if (m >= 80 || e >= 80) cout << "B";
			else cout << "C";
			cout << endl;
		}
	}
	return 0;
}

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

int main(){
  int n;
  while(cin >> n, n){
    for(int i=0; i<n; ++i){
      int m,e,j;
      cin >> m >> e >> j;
      if(m == 100 || e == 100 || j == 100){
        cout << "A" << endl;
      }else if((m + e)/2 >= 90){
        cout << "A" << endl;
      }else if((m + e + j)/3 >= 80){
        cout << "A" << endl;
      }else if((m + e + j)/3 >= 70){
        cout << "B" << endl;
      }else if((m + e + j)/3 >= 50){
        if(e >= 80 || m >=80){
          cout << "B" << endl;
        }else{
        cout << "C" << endl;
      }
      }else{
        cout << "C" << endl;
      }
    }
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
signed main()
{ 
  int a,b[20000],c[20000],d[20000];
  while(cin>>a,a!=0){
    for(int i=0;i<a;i++){
      cin>>b[i]>>c[i]>>d[i];
      if(b[i]==100 || c[i]==100 || d[i]==100){
	cout<<"A\n";
      }else if((b[i]+c[i])/2>=90){
	cout<<"A\n";
      }else if((b[i]+c[i]+d[i])/3>=80){
	cout<<"A\n";
      }else if((b[i]+c[i]+d[i])/3>=70){
	cout<<"B\n";
      }else if((b[i]+c[i]+d[i])/3>=50 && b[i]>=80 || c[i]>=80){
	cout<<"B\n";
      }else{
	cout<<"C\n";
      }
    }
  }
}

C++: #include<stdio.h>
int main(void)
{
	int n,m,e,j,i,cls[10000],flg;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			flg=0;
			scanf("%d %d %d",&m,&e,&j);
			if(m==100||e==100||j==100||(m+e)/2>=90||(m+e+j)/3>=80){
				cls[i]=1;
				flg=1;
			}
			if((m+e+j)/3>=70){
				flg++;
				cls[i]=2;
			}
			if((m+e+j)/3>=50&&(m>=80||e>=80)){
				flg++;
				cls[i]=2;
			}
			if(flg>=2){
				cls[i]=1;
			}
			if(flg=0){
				cls[i]=3;
			}
		}
		for(i=0;i<n;i++){
			if(cls[i]==1){
				printf("A\n");
			}
			if(cls[i]==2){
				printf("B\n");
			}
			if(cls[i]==3){
				printf("C\n");
			}

		}
	}
	return 0;
}

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

	return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,i,j,pm[10000],pe[10000],pj[10000],flg;
	
	while(1){
		flg=0;
		scanf("%d",&n);
		if(n==0) break;
		for(i=0;i<n;i++) scanf("%d %d %d",&pm[i],&pe[i],&pj[i]);
		for(i=0;i<n;i++){
			if(pm[i]==100 || pe[i]==100 || pj[i]==100) {
				printf("aA\n");
				flg=1;
			}
			else if((pm[i]+pe[i])/2>=90){
				printf("A\n");
				flg=1;
			}
			else if((pm[i]+pe[i]+pj[i])/3>=80){
				printf("A\n");
				flg=1;
			}
			else if((pm[i]+pe[i]+pj[i])/3>=70){
				printf("B\n");
				flg=1;
			}
			else if((pm[i]+pe[i]+pj[i])/3>=50){
				if(pm[i]>=80 || pe[i]>=80){
					printf("B\n");
					flg=1;
				}
			}
			else if(flg==0){
				printf("C\n");
			}
		}
	}
	return 0;
}

C++: #include <cstdio>
#include <utility>
using namespace std;

#define gcu getchar_unlocked
int in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;}
int in() {return in(gcu());}
bool scan(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bool scan(char &c){c=gcu();gcu();return c!=EOF;}
//bool scan(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename head, typename... tail>
bool scan(head &h, tail&&... t){return scan(h) && scan(t...);}
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
//vo(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail> vo(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T> vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef vo

int main() {
	for (int n; (n = in());)
		while (n--) {
			int a = in(), b = in(), c = in(), d = (a + b + c) / 3;
			out((a == 100 || b == 100 || c == 100 || a + b >= 180 || d >= 80) ? 'A' :
				(d >= 70 || (d >= 50 && (a >= 80 || b >= 80))) ? 'B' : 'C', '\n');
		}
}