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
    dataset = [map(int, input().split()) for _ in range(n)]
    for map_ in dataset:
        pm, pe, pj = map_
        x = (pm + pe + pj) // 3
        if 100 in map_:
            print("A")
        elif (pm + pe) // 2 >= 90:
            print("A")
        elif x >= 80:
            print("A")
        elif x >= 70:
            print("B")
        elif x >= 50 and (pm >= 80 or pe >= 80):
            print("B")
        else:
            print("C")

Python: 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 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])>179 or c>239 or 100 in a: b='A'
        elif c>209 or (c>149 and max(a[:2])>79): b='B'
        else: b='C'
        print(b)

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;        
}