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<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long UInt64;
typedef long long Int64;

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

using namespace std;

typedef pair<int ,int > P;

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

		string res="";

		if(a==100||b==100||c==100) res="A";
		else if(90 <= (a+b)/2) res="A";
		else if(80 <= (a+b+c)/3) res="A";
		else if(70 <= (a+b+c)/3) res="B";
		else if(50 <= (a+b+c)/3 &&(80<=a || 80<=b)) res="B";
		else res="C";

		cout<<res<<endl;

	}

}

int main()
{
	int n;
	while(cin>>n)
	{
		if(n==0) return 0;
		solve(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()
{
    while(1){
        int n;
        std::cin >> n;
        if(n==0){
            break;
        }
        for (int i=0; i<n; i++) {
            int pm,pe,pj;
            std::cin >> pm >>pe >>pj;
            std::cout << DividingStudent(pm, pe, pj) << std::endl;
        }
    }
}

C++: #include <iostream>
using namespace std;
int main(){
	int n,pm,pj,pe;
	while(n){
		cin>>n;
		for( int i=0; i<n; i++){
			cin>>pm>>pe>>pj;
			if(pm==100||pj==100||pe==100){
				cout<<"A"<<endl;
			}else if((pm+pe)/2>=90){
				cout<<"A"<<endl;
			}else if((pe+pj+pm)/3>=80){
				
			}
			else if((pm+pj+pe)/3>=70){
				cout<<"B"<<endl;
			}else if((pm+pe+pj)/3>=50&&pm>=80||pe>=80){
				cout <<"B"<<endl;
			}else{
				cout<<"C"<<endl;
			}
		}
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int pm,pe,pj;n>=1;n--){
		cin>>pm>>pe>>pj;
		if(pm==100||pe==100||pj==100)cout<<"A\n";
		else if(pm+pe>=180)cout<<"A\n";
		else if(pm+pe+pj>=240)cout<<"A\n";
		else if(pm+pe+pj>=210)cout<<"B\n";
		else if(pm+pe+pj>=150&&pm>=80||pe>=80)cout<<"B\n";
		else cout<<"C\n";
	}
}

C++: #include <iostream>
using namespace std;
int main(){
	int pj,pm,pe;
	while(1){
		int n;
		cin>>n;
		if(n==0) break;
		for(int i=1;i<=n; i++){
			cin>>pm>>pe>>pj;
			if(pm==100||pj==100||pe==100){
				cout<<"A"<<endl;
			}else if((pm+pe)/2>=90){
				cout<<"A"<<endl;
			}else if((pm+pe+pj)/3>=80){
				cout<<"A"<<endl;
			}else if((pm+pe+pj)/3>=70){
				cout<<"B"<<endl;
			}else if((pm+pe+pj)/3>=50&&pe>=80){
				cout<<"B"<<endl;

			}else if((pm+pe+pj)/3>=50&&pm>=80){
				cout<<"B"<<endl;
			}else{
				cout<<"C"<<endl;
			}
		}
	} 
}

C++: #include <stdio.h>

int divide(int, int, int);

int main(void)
{
	int n;
	while (1) {
		scanf("%d", &n);
		if (n == 0) 
			break;
	    int grade[n][3];
		for (int i = 0; i < n; i++) {
			scanf("%d %d %d", &grade[i][0], &grade[i][1], &grade[i][2]);
			divide(grade[i][0], grade[i][1], grade[i][2]);
		}
	}
	return 0;
}

int divide(int m, int e, int j)
{
	if (m == 100 || e == 100 || j == 100 ||
		(m + e) / 2 >= 90 ||
		(m + e + j) / 3 >= 80) {
		printf("A\n");
	} else if ((m + e + j) / 3 >= 70 ||
		       ((m + e + j) / 3 >= 50 && (m >= 80 || e >= 80))) {
		printf("B\n");
	} else {
		printf("C\n");
	}
	return 0;
}

C++: #include <stdio.h>

int main()
{
    int n;
    int jap, math, eng;
    int i, j;

    scanf("%d", &n);
    while (n != 0) {
        for (i = 0; i < n; i++) {
            scanf("%d %d %d", &math, &eng, &jap);

            if ((math == 100 || eng == 100 || jap == 100) ||
                (math + eng) >= 180 ||
                math + eng + jap >= 240) {
                printf("A\n");
            } else if ((math + eng + jap) >= 210 ||
                       ((math + eng + jap) >= 150 && (math >= 80 || eng >= 80))) {
                printf("B\n");
            } else {
                printf("C\n");
            }
        }

        scanf("%d", &n);
    }
    

    return 0;
}

C++: #include <stdio.h>

int main()
{
	int n,A,B,C;
	int pm,pe,pj;
	int i;

	scanf("%d",&n);

	while(n != 0){
		A = 0; B = 0; C = 0;
		for(i = 0; i < n; i++){
			scanf("%d%d%d",&pm,&pe,&pj);	
			if(pm == 100 || pe == 100 || pj == 100){
				printf("A\n");
			}
			else if((pm+pe)/2 >= 90){
				printf("A\n");
			}
			else if((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");
			}
		}

		scanf("%d",&n);
	}

	return 0;
}

C++: #include <stdio.h>

#define MYSCAN scanf

int main(void){
	int n, pm, pe, pj;

	while (true){

		MYSCAN("%d", &n);
		if (n == 0){ break; }
		for (int i = 0; i < n; i++){
			MYSCAN("%d%d%d", &pm, &pe, &pj);
			if (pm == 100 || pe == 100 || pj == 100){
				printf("A\n");
			}
			else if (pm + pe >= 180){
				printf("A\n");
			}
			else if (pm + pe + pj >= 240){
				printf("A\n");
			}
			else if (pm + pe + pj >= 210){
				printf("B\n");
			}
			else if (pm + pe + pj >= 150 && (pm >= 80 || pe >= 80)){
				printf("B\n");
			}
			else{
				printf("C\n");
			}	
		}
	}	
	return 0;
}

C++: #include <stdio.h>
char class(int pm, int pe, int pj);

int main(void)
{
    int n, pm, pe, pj;
    scanf("%d", &n);
    for (int i = 0;i < n;i ++){
	scanf("%d %d %d", &pm, &pe, &pj); 
	printf("%c\n", class(pm, pe, pj));
    }
    return 0;
}

char class(int pm, int pe, int pj)
{
    int ave = (pm + pe + pj) / 3;
    if (pm == 100 || pe == 100 || pj == 100){
	return 'A';
    } else if ((pm + pe) / 2 >= 90){
	return 'A';
    } else if (ave >= 80){
	return 'A';
    } else if (ave >= 70){
	return 'B';
    } else if (ave >= 50 && (pm >= 80 || pe >= 80)){
	return 'B';
    } else {
	return 'C';
    }
}

C++: #include<bits/stdc++.h>
using namespace std;
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((m==100||e==100||j==100)||(m+e)/2>=90||(m+e+j)/3>=80){
	cout<<'A'<<endl;
	continue;
      }else  if((m+e+j)/3>=70||((m+e+j)/3>=50&&m>=80||e>=80)){
	cout<<'B'<<endl;
	continue;
      }else{
	cout<<'C'<<endl;
      }
    }
  }
  return(0);
}

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

int n, m, e, j;

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

	return 0;
}