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")
			}
		}
	}
}

Python: while True:
    n = int(input())
    if n == 0:
        break
    
    for _ in range(n):
        m, e, j = [int(x) for x in input().split()]
        
        if m == 100 or e == 100 or j == 100:
            print("A")
            continue
        if m + e >= 180:
            print("A")
            continue
        if m + e + j >= 240:
            print("A")
            continue
        if m + e + j >= 210:
            print("B")
            continue
        if m + e + j >= 150 and (m >= 80 or e >=80):
            print("B")
            continue
        print("C")

Python: while True:
    n = int(input())
    if n == 0:
        break
    for _ in range(n):
        a,b,c = map(int,input().split())
        if a == 100 or b == 100 or c == 100 or a+b >= 180 or a+b+c >= 240:
            print("A")
        elif a+b+c >= 210 or (a+b+c >= 150 and (a >= 80 or b >= 80)):
            print("B")
        else:
            print("C")

Python: while True:
    n = int(input())
    if n==0: break

    for i in range(n):
        m,e,j = map(int,input().split())
        if (m==100 or e==100 or j ==100) or ((m+e)/2 >= 90) or ((m+e+j)/3 >=80):
            print("A")
        elif((m+e+j)/3 >=70) or (((m+e+j)/3>=50) and (m>=80 or e>=80)):
            print("B")
        else:
            print("C")

Python: while True:
  n=int(input())
  if n==0:
    break
  for i in range(n):
    m,e,j=map(int,input().split())
    if m==100 or e==100 or j==100:
      print('{}'.format('A'))
    elif ((m+e)/2)>=90:
       print('{}'.format('A'))
    elif ((m+e+j)/3)>=80:
       print('{}'.format('A'))
    elif ((m+e+j)/3)>=70:
       print('{}'.format('B'))
    elif ((m+e+j)/3)>=50:
      if m>=80 or e>=80:
          print('{}'.format('B'))
      else:
        print('{}'.format('C'))
    else:
      print('{}'.format('C'))

Python: # AOJ 0218: Dividing Students
# Python3 2018.6.23 bal4u

while 1:
	n = int(input())
	if n == 0: break
	for i in range(n):
		pm, pe, pj = map(int, input().split())
		k = pm+pe+pj
		if pm == 100 or pe == 100 or pj == 100: print("A")
		elif pm + pe >= 90*2: print("A")
		elif k >= 80*3: print("A")
		elif k >= 70*3: print("B")
		elif k >= 50*3 and (pm >= 80 or pe >= 80): print("B")
		else: print("C")

Python: while True:

    N = int(input())
    if N == 0:
        break

    for l in range(N):
        m,e,j = [int(i) for i in input().split()]

        ans = ""
        if m == 100 or e == 100 or j == 100:
            ans = "A"
        elif m + e >= 180:
            ans = "A"
        elif m + e + j >= 240:
            ans = "A"
        elif m + e + j >= 210:
            ans = "B"
        elif (m + e + j >= 150) and (m >= 80 or e >= 80):
            ans = "B"
        else:
            ans = "C"

        print(ans)

Python: while 1:
    n=int(input())
    if n=='0': break
    for _ in range(n):
        a=list(map(int,input().split()))
        c=sum(a)
        if sum(a[:2])/2>=90 or c/3>=80 or 100 in a: b='A'
        elif c/3>=70 or (c/3>=50 and (a[0]>=80 or a[1]>=80)): b='B'
        else: b='C'
        print(b)

Python: while True:
    #繰り返し回数を入力し0であった場合はbreakする
    num = int(input())
    if num == 0:
        break
    else:
        for _ in range(num):
            a,b,c = map(int,input().split())
            
            #100 点の科目があるまたは数学と英語の平均点が 90 点以上または3 科目の平均点が 80 点以上の場合"A"を出力する
            if a == 100 or b == 100 or c == 100 or (a + b) / 2 >= 90 or (a + b + c) / 3 >= 80:print("A")
            
            #3 科目の平均点が 70 点以上または3 科目の平均点が 50 点以上で数学か英語が 80 点以上の場合"B"を出力する
            elif (a + b + c) / 3 >= 70 or (a + b + c) / 3 >= 50 and a >= 80 or (a + b + c) / 3 >= 50 and b >= 80:print("B")
            
            #上記のどれにも当てはまらない場合、"C"を出力する
            else:print("C")

Python: while True:
    n=int(input())
    if n==0:
        break
    for i in range(n):
        s,e,k=map(int,input().split())
        if k==100 or s==100 or e==100:
            print("A")
        elif (s+e)/2 >=90:
            print("A")
        elif (s+k+e)/3 >=80:
            print("A")
        elif (s+k+e)/3 >=70:
            print("B")
        elif (s+k+e)/3 >=50 and s>=80:
            print("B")
        elif (s+k+e)/3 >=50 and e>=80:
            print("B")
        else:
            print("C")

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

int main(){
    int n, a, b, c, i , ans;
    while(scanf("%d", &n) != 0){
        if(n == 0) break;
        for(i = 0; i < n; i++){
            ans = 0;
            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) ans++;
                if((a + b + c) / 3 >= 50 && b >= 80) ans++;
            }
            if(ans > 1) printf("A\n");
            if(ans == 1) printf("B\n");
            if(ans == 0) printf("C\n");
        }
    }
    return 0;
}

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

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

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

int main(){
   char c[10001];
   int m,e,j;
   int n;
   
   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) c[i]='A';
         else if(m+e>=180) c[i]='A';
         else if(m+e+j>=240) c[i]='A';
         else if(m+e+j>=210) c[i]='B';
         else if(m+e+j>=150&&m>=80) c[i]='B';
         else if(m+e+j>=150&&e>=80) c[i]='B';
         else c[i]='C';
      }
      for(int i=0; i<n; i++) cout << c[i] << endl;
   }
   return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

main(){
	while(true){
		int n;
		cin>>n;
		
		if(n<=0){
			break;
		}
		
		for(int i=0; i<n; ++i){
			// 数学の点数、英語の点数、国語の点数 pj
			int m,e,j;
			cin>>m>>e>>j;
			
			if(m==100||e==100||j==100||m+e>=90*2||m+e+j>=80*3){
				puts("A");
			}else if(m+e+j>=70*3||(m+e+j>=50*3&&(m>=80||e>=80))){
				puts("B");
			}else{
				puts("C");
			}
			
		}
	}
}