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<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
    for(;;){
	int n;
	cin>>n;
	if(n==0)break;
	int a[1010],b[1010],c[1010];
	char d[1010];

	for(int i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];

	}
	for(int i=0;i<n;i++){
        if(a[i]==100||b[i]==100||c[i]==100){
            d[i]='A';
        }
        else if((a[i]+b[i])/2>=90)d[i]='A';


        else if((a[i]+b[i]+c[i])/3>=80)d[i]='A';

        else if((a[i]+b[i]+c[i])/3>=70)d[i]='B';

        else if((a[i]+b[i]+c[i])/3>=50&&a[i]>=80)d[i]='B';

        else if((a[i]+b[i]+c[i])/3>=50&&b[i]>=80)d[i]='B';

        else d[i]='C';

	}
	for(int i=0;i<n;i++){
        cout<<d[i]<<endl;
	}

    }
	return 0;
}

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

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <stack>
#include <list>

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,b,n) for(int i=b;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

const float PI = 3.1415926;
static const int INFTY = (1<<30);

using namespace std;

typedef long long ll;
typedef long double ld;

int n;

int main() {
  while(cin >> n, n) {
    rep(i, n) {
      int pm, pe, pj;
      cin >> pm >> pe >> pj;
      float tmp1 = (pm + pe) / 2.0;
      float tmp2 = (pm + pe + pj) / 3.0;
      if(tmp1 => 90 || tmp2 => 80 || pm == 100 || pe == 100 || pj == 100) {
        cout << 'A' << endl;
      } else if (tmp2 => 70 || (tmp2 => 50 && (pm => 80 || pe => 80))) {
        cout << 'B' << endl;
      } else {
        cout << 'C' << endl;
      }
    }
  }
  return 0;
}

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

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

int grade(int pm, int pe, int pj);

int main(void){
  int n;
  int pm,pe,pj;
  while(1){
    cin>>n;
    if(n==0){break;}
    for(int i=0;i<n;i++){
      cin>>pm>>pe>>pj;
      cout<<(char)(grade(pm,pe,pj)+'A')<<endl;
    }
  }
  return 0;
}

int grade(int pm, int pe, int pj){
  if(pm==100 or pe==100 or pj==100){return 0;}
  if(pm+pe>=180){return 0;}
  if(pm+pe+pj>=240){return 0;}
  else if(pm+pe+pj>=70*3){return 1;}
  else if((pm+pe+pj>=50*3) and (pe>=80 or pm>=80)){return 1;}
  else{return 2;}
}

C++: #include <stdio.h>
char classify(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", classify(pm, pe, pj));
    }
    return 0;
}

char classify(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<iostream>
using namespace std;
int main(){
	int n,a,b,c;
	while(cin>>n,n){
		while(n--){
			cin>>a>>b>>c;
			if((a==100||b==100||c==100)||a+b>=180||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;
		}
	}
	return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<iostream>
using namespace std;
int main(void)
{
	int a,b,c;
	int i,j;
	int n;
	while(1) {
		cin >> n;
		if(n==0)break;
		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;
		}
	}
	exit(0);
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
char hyakuten(int students[][3],int n){
  for(int i=0;i<3;i++){
   if(students[n][i]==100)return 'A';
  }
  if((students[n][0]+students[n][1])/2>=90)return 'A';
  if((students[n][0]+students[n][1]+students[n][2])/3>=80)return 'A';
  if((students[n][0]+students[n][1]+students[n][2])/3>=70)return 'B';
  if((students[n][0]+students[n][1]+students[n][2])/3>=50&&students[n][0]>=80||students[n][1]>=80)return 'B';
  return 'C';
}


int main(){
  int n;
  while(cin>>n&&n){
    int students[10000][3];
    for(int i=0;i<n;i++){
      for(int j=0;j<3;j++){
        cin>>students[i][j];
      }
    }
    for(int i=0;i<n;i++){
      cout<<hyakuten(students[i][],i)<<endl;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>

using namespace std;

int main(){
    int n, pm, pe, pj;
    while(cin >> n, n){
	while(n--){
	    cin >> pm >> pe >> pj;
	    if(pm == 100 || pe == 100 || pj == 100){
		cout << "A" << endl;
		continue;
	    }
	    if(pm + pe >= 180){
		cout << "A" << endl;
		continue;
	    }
	    if(pm + pe + pj >= 240){
		cout << "A" << endl;
		continue;
	    }
	    if(pm + pe + pj >= 210){
		cout << "B" << endl;
		continue;
	    }
	    if(pm + pe + pj >= 150 && (pm >= 80 || pe >= 80)){
		cout << "B" << endl;
		continue;
	    }
	    cout << "C" << 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;

  }