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

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: def rank(pm, pe, pj):
    ave_me = (pm + pe) // 2
    ave_all = (pm + pe + pj) // 3

    if 100 == pm or 100 == pe or 100 == pj or 90 <= ave_me or 80 <= ave_all:
        return 'A'
    
    if 70 <= ave_all or 50 <= ave_all and (80 <= pm or 80 <= pe):
        return 'B'
    return 'C'

import sys
f = sys.stdin

while True:
    n = int(f.readline())
    if n == 0:
        break
    for _ in range(n):
        pm, pe, pj = map(int, f.readline().split())
        print(rank(pm, pe, pj))

Python: n=int(input())
while True:
  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'))