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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-8;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		while (n--)
		{
			int m, e, j;
			scanf("%d%d%d", &m, &e, &j);
			int ave = (m + e + j) / 3;
			int r = 0;
			if (m == 100 || e == 100 || j == 100
				|| (m + e) / 2 >= 90
				|| ave >= 80)
				r = 2;
			if (ave >= 70)
				++r;
			if (ave >= 50 && (m >= 80 || e >= 80))
				++r;

			printf("%c\n", r == 0 ? 'C' : (r == 1 ? 'B' : 'A'));
		}
	}

	return 0;
}

C++: #include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int n,pm,pe,pj;
char cls()
{
	if(max(pm,max(pe,pj))==100||pm+pe>=180||pm+pe+pj>=240)return 'A';
	if(pm+pe+pj>=210||pm+pe+pj>=150&&max(pm,pe)>=80)return 'B';
	return 'C';
}
int main()
{
	while(scanf("%d",&n),n)
	{
		rep(i,n)
		{
			scanf("%d%d%d",&pm,&pe,&pj);
			printf("%c\n",cls());
		}
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n,pj,pm,pe;
	while(n){
		cin>>n;
		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&&pm>=80||pe>=80){
				cout<<"B"<<endl;
			}else{
				cout<<"C"<<endl;
			}
		}
	}
}

C++: #include<stdio.h>
int main(void)
{
	int n,m,e,j,i,cls[10000],flg;
	while(1){
		scanf("%d",&n);
		if(n<1)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>=90*2){
				cls[i]=1;
				flg++;
			}
			if(m+e+j>=80*3){
				cls[i]=1;
				flg++;
			}
			if(m+e+j>=70*3){
				cls[i]=2;
				flg++;
			}
			if(m+e+j>=50*3&&(m>=80||e>=80)){
				cls[i]=2;
				flg++;
			}
			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>

void dividing(int pm, int pe, int pj);

int main(void)
{
  int n;
  int pm, pe, pj;
  while (1) {
    int i = 0;
    scanf("%d", &n);
  if (n == 0) {
    break;
  } else {
  while (i < n) {
    scanf("%d %d %d", &pm, &pe, &pj);
    dividing(pm, pe, pj);
    i++;
  }
  }
  }
  return 0;
}

void dividing(int pm, int pe, int pj)
{
  if (pm == 100 || pe == 100 || pj == 100) {
    printf("A\n");
  }
  else if (pm + pe >= 90 * 2){
    printf("A\n");
  }
  else if (pm + pe + pj >= 80 * 3){
    printf("A\n");
  }
  else if (pm + pe + pj >= 70 * 3){
    printf("B\n");
  }
  else if((pm + pe + pj >= 50 * 3) && (pm > 80 || pe > 80)){
    printf("B\n");
  } else {
    printf("C\n");
  }
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int i,j,k,n,a,b,c;
	while(cin>>n&&n) {
		for(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;
		}
	}
}

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(){
	while(1){
		int n,m,e,j;
		int i;
		scanf("%d",&n);
		if(n==0)return 0;
		for(i=0;i<n;i++){
			scanf("%d %d %d",&m,&e,&j);
			if((m==100||e==100||j==100)||m+e>=180||m+e+j>=240)printf("A\n");
			else if(m+e+j>=210||(m+e+j>=150&&(m>=80||e>=80)))printf("B\n");
			else printf("C\n");
		}
	}
}

C++: #include <stdio.h>

float mean2(int x, int y)
{
    return (float)(x + y) / 2.0;
}

float mean3(int x, int y, int z)
{
    return (float)(x + y + z) / 3.0;
}

char grading(int p_math, int p_eng, int p_jpn)
{
    if ( p_math == 100 || p_eng == 100 || p_jpn == 100) {
        return 'A';
    } else if (mean2(p_math, p_eng) >= 90.0) {
        return 'A';
    } else if (mean3(p_math, p_eng, p_jpn) >= 80.0) {
        return 'A';
    } else if (mean3(p_math, p_eng, p_jpn) >= 70.0) {
        return 'B';
    } else if (mean3(p_math, p_eng, p_jpn) >= 70.0 && (p_math >= 80 || p_eng >= 80)) {
        return 'B';
    } else {
        return 'C';
    }
}

int main(void)
{
    int i, p_math, p_eng, p_jpn, n_iteration;
    char grade;

    scanf("%d", &n_iteration);

    for (i = 0; i < n_iteration; i++) {
        scanf("%d %d %d", &p_math, &p_eng, &p_jpn);
        grade = grading(p_math, p_eng, p_jpn);
        printf("%c\n", grade);
    }
    return 0;
}

C++: #include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
using namespace std;
int main(){
int n;
while(cin>>n,n){
rep(i,n){
int a,b,c;
cin>>a>>b>>c;
if((a==100||b==100||c==100)||(a+b)/2>=90||a+b+c>=240)cout<<'A'<<endl;
else if(a+b+c>=210||(a+b+c>=150&&(a>=80||b>=80)))cout<<'B'<<endl;
else cout<<'C'<<endl;
}
}
}