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 <bits/stdc++.h>

#define rep_(v, f, l) for (int v = (f); v < (l); ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

int main()
{
    int n;
    while (n = in()){
        rep(i, n){
            int pm, pe, pj;
            pm = in();
            pe = in();
            pj = in();
            int all_ave = (pm + pe + pj) / 3;
            int me_ave = (pm + pe) / 2;
            int is_perfect = pm == 100 || pe == 100 || pj == 100;
            if (is_perfect || me_ave >= 90 || all_ave >= 80 || (all_ave >= 70 && max(pm, pe) >= 80)){
                puts("A");
            }
            else if (all_ave >= 70 || (all_ave >= 50 && max(pm, pe) >= 80)){
                puts("B");
            }
            else {
                puts("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||(m+e)/2>=90||(m+e+j)/3>=80){
				cls[i]=1;
				flg=1;
			}
			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;
}

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

C++: #include <iostream>
#include <string>
using namespace std;
int main()
{
	int n, e, m, j, i;
	double a;
	string s;
	while (cin >> n && n)
	{
		s = "";
		for (i = 0; i < n; i++)
		{
			cin >> m >> e >> j;
			a = ((double)m+e+j)/3;
			if (m == 100 || e == 100 || j == 100 || (m+e)/2 >= 90 || a >= 80)
				s += "A\n";
			else if (a >= 70 || (a >= 50 && (m >= 80 || e >= 80)))
				s += "B\n";
			else
				s += "C\n";
		}
		cout << s;
	}
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>

using namespace std;

int main(int argc, char *argv[]) {
  int n, 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 ((pm + pe) / 2 >= 90)
        cout << 'A' << endl;
      else if ((pm + pe + pj) / 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++: #define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

static const double eps = 1e-8;

int getAvr(int* p,int n){
	int sum = 0;
	for(int i=0;i<n;i++){
		sum += p[i];
	}

	return sum/3;
}

int main(){
	int n;	
	while(~scanf("%d",&n)){	
		if(n==0) break;
		
		for(int i=0;i<n;i++){
			int p[3];
			//math,english,japanese			
			scanf("%d %d %d",p,p+1,p+2);

			for(int i=0;i<3;i++){
				if(p[i]==100){
					printf("A\n");
					goto next;
				}
			}

			if(p[0] + p[1] >= 180 || getAvr(p,3) >= 80){
				printf("A\n");
			}

			else if(getAvr(p,3) >= 70
				|| (getAvr(p,3) >= 50 && (p[0] >= 80 || p[1] >= 80))){
				printf("B\n");
			}

			else{
				printf("C\n");
			}
next:;

		}
		
	}
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n,m,e,j;
	char z;
	while(true){
	cin>>n;
	if(n==0)
		break;
	for(int i=0;i<n;i++){
		cin>>m>>e>>j;
		z='C';
		if(m+e+j>=210)
			z='B';
		if(m+e+j>=150&&(m>=80||e>=80))
			z='B';
		if(m==100||e==100||j==100)
			z='A';
		if(m+e>=180)
			z='A';
		if(m+e+j>=240)
			z='A';
		cout<<z<<endl;
	}
	}
    return 0;
}

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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか) */

  int n;

  int a,b,c;


  while(1){
    cin>>n;

    if(n==0){
      break;
    }
    for(int i=0;i<n;i++){
      cin>>a>>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||b>=80)){
	cout<<'B'<<endl;
      }else{
	cout<<'C'<<endl;
      }
    }

  }
    return 0;

  }

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

C++: #include <iostream>
using namespace std;
char judge_class(int, int, int);

int main(void)
{
    int pm, pe, pj, n;
    while (true) {
        cin >> n;
        if (n == 0) break;
        for (int i = 0; i < n; i++) {
            cin >> pm >> pe >> pj;
            cout << judge_class(pm, pe, pj) << endl;
        }
    }
    return 0;
}

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