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() {
	int n;
	while (cin >> n&&n != 0) {
		for (int i = 0; i < n; i++) {
			int e, f, g, a = 0, b = 0, c = 0;
			char l;
			cin >> e >> f >> g;
			if (e == 100 || f == 100 || g == 100)
				a++;
			if ((e + f) / 2 >= 90)
				a++;
			double d = (e + f + g) / 3;
			if (d >= 80)
				a++;
			if (d >= 70)
				b++;
			if (d >= 50 && (e >= 80 || f >= 80))
				b++;
			if (a != 0 || b >= 2)
				cout << 'A' << endl;
			else if (b != 0)
				cout << 'B' << endl;
			else
				cout << 'C' << endl;
		}
	}
}

C++: #include<stdio.h>
 
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 >= 2) printf("A\n");
            if(ans == 1) printf("B\n");
            if(ans == 0) printf("C\n");
        }
    }
    return 0;
}

C++: 
#include <stdio.h>
#include<math.h>
#include <algorithm>
using namespace std;

int main(){
	int n,a,b,c;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		for(int i = 0; i < n; i++){
			scanf("%d %d %d",&a,&b,&c);
			if(a == 100 || b == 100 || c == 100 || a + b >= 180 || a+b+c >= 240){
				printf("A\n");
			}else if((a + b + c >= 210) || (a+b+c>=150 && (a >= 80 || b >= 80))){
				printf("B\n");
			}else{
				printf("C\n");
			}
		}

	}
    return 0;
}

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

Python: while True:
    n = int(input())
    if n == 0:
        break
    dataset = [list(map(int, input().split())) for _ in range(n)]
    for p in dataset:
        x = (p[0] + p[1] + p[2]) // 3
        if 100 in p:
            print("A")
        elif (p[0] + p[1]) // 2 >= 90:
            print("A")
        elif x >= 80:
            print("A")
        elif x >= 70:
            print("B")
        elif x >= 50 and (p[0] >= 80 or p[1] >= 80):
            print("B")
        else:
            print("C")

Python: while True:
    n = int(input())
    if n==0:
        break
    for i in range(n):
        m,e,j = [ int(s) for s in input().split() ]
        if m == 100 or e == 100 or j == 100:
            print('A')
        elif (m+e)/2 >= 90:
            print('A')
        elif (m+e+j)/3 >= 80:
            print('A')
        elif (m+e+j)/3 >= 70:
            print('B')
        elif (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
    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 p:
            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):
        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 1:
    n = int(input())
    if n == 0:
        break
    l = [list(map(int,input().split())) for i in range(n)]
    for i in range(n):
        if l[i][0] == 100 or l[i][1] == 100 or l[i][2] == 100:
            print("A")
        elif l[i][0] + l[i][1] >= 180:
            print("A")
        elif l[i][0] + l[i][1] + l[i][2] >= 240:
            print("A")
        elif l[i][0] + l[i][1] + l[i][2] >= 210:
            print("B")
        elif l[i][0] + l[i][1] + l[i][2] >= 150 and (l[i][0] >=80 or l[i][1] >=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("A")
        elif (m + e) / 2 >= 90 :
            print("A")
        elif (m + e + j) / 3 >= 80 :
            print("A")
        elif (m + e + j) / 3 >= 70 :
            print("B")
        elif (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 _ in range(N):
        m, e, j = map(int, input().split())
        me, mej = (m+e)//2, (m+e+j)//3
        if 100 in (m, e, j) or me >= 90 or mej >= 80:
            print('A')
        elif mej >= 70 or (mej >= 50 and m >= 80 or e >= 80):
            print('B')
        else:
            print('C')

Python: while True:
    n = int(input())
    if n == 0:
        break
    dataset = [list(map(int, input().split())) for _ in range(n)]
    for p in dataset:
        x = sum(p) // 3
        if 100 in p:
            print("A")
        elif (p[0] + p[1]) // 2 >= 90:
            print("A")
        elif x >= 80:
            print("A")
        elif x >= 70:
            print("B")
        elif x >= 50 and (p[0] >= 80 or p[1] >= 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])/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: def rank(m, e, j):
  if 100 in (m, e, j) or (m + e) / 2 >= 90 or (m + e + j) / 3 >= 80:
    return "A"
  elif (m + e + j) / 3 >= 70 or ((m + e + j) / 3 >= 50 and (m >= 80 or e >= 80)):
    return "B"
  return "C"

while True:
  n = int(input())
  if n == 0:
    break
  for _ in range(n):
    m, e, j = map(int, input().split())
    print(rank(m, e, j))

Python: def bar(a,b,c):
  x=(a+b+c)/3
  return x
while True:
  n=int(input())
  if n==0:
    break
  for i in range(n):
    m,e,j=map(int, input().split())
    y=(m+e)/2
    x =bar(m,e,j)
    if (m==100 or e==100 or j==100) or y>=90 or x>=80:
      print("A")
    elif x>=70:
      print("B")
    elif x>=50:
      if m>=80 or e>=80:
        print("B")
      else:
        print("C")
    else:
      print("C")