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>
using namespace std;
int main(void){
  int n;
  int e,m,j;
  while(cin>>n&&n!=0){
    for(int i=0;i<n;i++){
      cin>>m>>e>>j;
      if(m==100||e==100||j==100){
	cout<<"A";
      }else if((m+e)/2>=90){
	cout<<"A";
      }else if((m+e+j)/3>=80){
	cout<<"A";
      }else if((m+e+j)/3>=70){
	cout<<"B";
      }else if((m+e+j)/3>=50&&(m>=80||e>=80)){
	cout<<"B";
      }else{
	cout<<"C";
      }
      cout<<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 <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+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||(pm+pe+pj)/3>=50&&pe>=80){
				cout<<"B"<<endl;
			}else{
				cout<<"C"<<endl;
			}
		}
	}
}

C++: #include <stdio.h>

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

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

    while (1){
        scanf("%d", &dataset);
        if (dataset == 0){
            break;
        } else {
            while (dataset--){
                scanf("%d %d %d", &pm, &pe, &pj);
                judge(pm, pe, pj);
            }
        }
    }

    return 0;
}

void judge(int pm, int pe, int pj)
{
    char class;

    if (pm == 100 || pe == 100 || pj == 100){
        class = 'A';
    } else if (pm + pe >= 180){
        class = 'A';
    } else if (pm + pe + pj >= 240){
        class = 'A';
    } else if (pm + pe + pj >= 210){
        class = 'B';
    } else if (pm + pe + pj >= 150 && (pm >= 80 || pe >= 80)){
        class = 'B';
    } else {
        class = 'C';
    }

    printf("%c\n", class);
}

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

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>

//#define PI 3.141592653589

using namespace std;



int main()
{
	int n;
	int pm[10000], pe[10000], pj[10000];
	
	while (1)
	{
		cin >> n;
		if (n == 0) break;
		
		for (int i=0; i<n; i++)
		{
			cin >> pm[i] >> pe[i] >> pj[i];
			if (pm[i]==100 || pe[i]==100 || pj[i]==100)
			{
				cout << "A" << endl;
			} else if ((pm[i]+pe[i]) / 2 >= 90) {
				cout << "A" << endl;
			} else if ((pm[i]+pe[i]+pj[i]) / 3 >= 80) {
				cout << "A" << endl;
			} else if ((pm[i]+pe[i]+pj[i]) / 3 >= 70) {
				cout << "B" << endl;
			} else if (((pm[i]+pe[i]+pj[i]) / 3 >= 50) && (pm[i] >= 80 || pe[i] >= 80)) {
				cout << "B" << endl;
			} else {
				cout << "C" << endl;
			}
		}
	}
	
	return 0;
}

C++: #include <stdio.h>

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

int main(void)
{
    int n; //, pm, pe, pj;
    while (1) {
        scanf("%d", &n);
        if (n == 0) {
            break;
        }
        int pm[n], pe[n], pj[n];
        for (int i = 0; i < n; i++) {
            scanf("%d %d %d",&pm[i], &pe[i], &pj[i]);
        }
        for (int i = 0; i < n; i++) {
          printf("%c\n", judge(pm[i], pe[i], pj[i]));
        }
    }
    return 0;
}

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

C++: #include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
const int MOD = 1000000009;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  int m, e, j;
  
  cin >> n;
  while(n != 0){
    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;
      }else if((m + e + j) / 3 >= 70 || ((m + e + j) / 3 >= 50 && m >= 80 || e >= 80)){
	cout << "B" << endl;
      }else{
	cout << "C" << endl;
      }
    }
    cin >> n;
  }
  return 0;
}

C++: #include <stdio.h>
#include <stdbool.h>

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