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++: /*100 点の科目がある 	A
数学と英語の平均点が 90 点以上 	A
3 科目の平均点が 80 点以上 	A
3 科目の平均点が 70 点以上 	B
3 科目の平均点が 50 点以上で数学か英語が 80 点以上 	B
上の条件を満たさない 	C*/
#include<iostream>
using namespace std;
int main(){
	for(;;){
		int n;
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			int a,b,c;
			cin>>a;
			cin>>b>>c;
			if(a==100||b==100||c==100){
				cout<<"A"<<endl;
			}	
			else if((a+b)/2>=90){
				cout<<"A"<<endl;
			}
			else if((a+b+c)/3>=80){
				cout<<"A"<<endl;
			}
			else if((a+b+c)/3>=70){
				cout<<"B"<<endl;
			}
			else if((a+b+c)/3>=50&&a>=80){
				cout<<"B"<<endl;
			}	
			else if((a+b+c)/3>=50&&b>=80){
				cout<<"B"<<endl;
			}
			else{
				cout<<"C"<<endl;
			}
		}
	}
}

C++: #include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N;
    while(cin>>N){
        if(!N)break;
        for(int i=0;i<N;i++){
            int su,ei,koku;
            cin>>su>>ei>>koku;
            if(su==100||ei==100||koku==100||180<=su+ei||240<=su+ei+koku)puts("A");
            else if(210<=su+ei+koku||(150<=su+ei+koku&&(80<=su||80<=ei)))puts("B");
            else puts("C");
        }
    }
    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include <cstring>
#include<map>
#include<string>
#include<stack>
#include <sstream>
#include<vector>
using namespace std;


int main(){
	int n;
	while(cin>>n)
	{
		if(n==0)break;
		while(n--)
		{
			int ei,suu,koku;
			cin>>suu>>ei>>koku;
			if( suu==100 || ei==100 || koku==100 ) puts("A");
			else if( (suu+ei)/2 >= 90 ) puts("A");
			else if( (suu+ei+koku)/3 >=80 ) puts("A");
			else if( (suu+ei+koku)/3 >=70 ) puts("B");
			else if( (suu+ei+koku)/3 >=50  && (suu>=80 || ei>=80 ) ) puts("B");
			else puts("C");
		}
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#define rep(i,n) for(int i=0;i<(int)n;i++)

using namespace std;

string ten[3]={"A","B","C"};

int main()
{
	int n;
	cin>>n;
	for(;n!=0;cin>>n)
	{
		rep(i,n)
		{
			int ma,en,ja;
			int ans=2;
			cin>>ma>>en>>ja;
			
			if(((ma+en+ja)/3>=50&&(ma>=80||en>=80))||(ma+en+ja)/3>=70)ans=1;
			if((ma+en+ja)/3>=80||(ma+en)/2>=90||en==100||ja==100||ma==100)ans=0;
			
			cout<<ten[ans]<<endl;
		}
		
		
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){

  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,pm[10010],pe[10010],pj[10010];
  int ps[10010];
  
  while(1){
    cin>>n;
    if(n==0) break;
    
    for(int i=0; i<n; i++){
      cin>>pm[i]>>pe[i]>>pj[i];
      ps[i]=pm[i]+pe[i]+pj[i];
      
      if(pm[i]==100 || pe[i]==100 || pj[i]==100){
	cout<<"A"<<'\n';
	
    }else if((pm[i]+pe[i])/2>=90){
	cout<<"A"<<'\n';
	
      }else if(ps[i]/3>=80){
	cout<<"A"<<'\n';
	
      }else if(ps[i]/3>=70){
	cout<<"B"<<'\n';
	
      }else if(ps[i]/3>=50 && pm[i]>=80 || pe[i]>=80){
	cout<<"B"<<'\n';
	
      }else{
	cout<<"C"<<'\n';
      }
    }
  }
  return 0;
}

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

int main(){
    int n;

    while(cin >> n, n != 0){
        for(int i=1; i<=n; i++){
            int pm, pe, pj;
            cin >> pm >> pe >> pj;
            double all_ave = (pm+pe+pj) / 3.0;
            double me_ave = (pm+pe) / 2.0;

            if(pm == 100 || pe == 100 || pj == 100) cout << "A" << endl;
            else if(me_ave >= 90.0) cout << "A" << endl;
            else if(all_ave >= 80.0) cout << "A" << endl;
            else if(all_ave >= 70.0) cout << "B" << endl;
            else if(all_ave >= 50 && (pm >= 80) || (pe >= 80)) cout << "B" << endl;
            else cout << "C" << endl;
        }
    }
    return 0;
}

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

int main(){
	int n, pm, pe, pj;
	while(1){
		cin>>n;
		if(n==0) break;

		for(int i=0;i<n;i++){
			cin>>pm>>pe>>pj;
			double ave = (pm + pe + pj)/3;
			if(( pm == 100 | pe == 100 | pj == 100 ) | ((pm+pe)/2 >= 90 ) | ( ave >= 80) )  cout<<"A"<<endl;
			else if(( ave >= 70 ) | (( ave >= 50 ) && ( pm >= 80 | pe >= 80 )))             cout<<"B"<<endl;
			else                                                                            cout<<"C"<<endl;
		}
	}

	return 0;
}

C++: #include<iostream>

char *c;
int n,pm,pe,pj;

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

int main(){
	while(true){
		std::cin >> n;
		if(!n)
			return 0;
		c = new char[n];
		for(int i=0; i<n; i++){
			std::cin >> pm >> pe >> pj;
			c[i] = solve(pm, pe, pj);
		}
		for(int i=0; i<n; i++)
			std::cout << c[i] << std::endl;
		delete[] c;
	}
	return 0;
}

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){
				cls[i]=1;
				flg++;
			}
			if((m+e)/2>=90){
				cls[i]=1;
				flg++;
			}
			if((m+e+j)/3>=80){
				cls[i]=1;
				flg++;
			}
			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<1){
				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,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++;
			}
			if((m+e+j)/3>=70&&(m+e+j)/3<80){
				flg++;
				cls[i]=2;
			}
			if(((m+e+j)/3>=50&&(m+e+j)/3<80)&&((m>=80&&m<100)||(e>=80&&e<100))){
				flg++;
				cls[i]=2;
			}
			if(flg>=2){
				cls[i]=1;
			}
			if(flg<1){
				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;
}