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

Python: # -*- coding: utf-8 -*-
"""
Dividing Students
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0218

"""
import sys


def solve(n):
    ans = []
    for _ in range(n):
        m, e, j = map(int, input().split())
        if max([m, e, j]) == 100 or m + e >= 180 or m + e + j >= 240:
            ans.append('A')
        elif m + e + j >= 210 or (m + e + j >= 150 and (m >= 80 or e >= 80)):
            ans.append('B')
        else:
            ans.append('C')
    return ans


def main(args):
    while True:
        n = int(input())
        if n == 0:
            break
        ans = solve(n)
        print(*ans, sep='\n')


if __name__ == '__main__':
    main(sys.argv[1:])

Python: while True:
    n = int(input())
    if n == 0:
        break
    for i in range(n):
        p = list(map(int,input().split()))
        if max(p)==100 or sum(p[:2])>=180 or sum(p)>=240:
            print('A')
        elif sum(p)>=210 or (sum(p)>=150 and max(p[:2])>=80):
            print('B')
        else:
            print('C')

Python: 
def a1(li):
    if 100 in li: return 1
    else: return 0

def a2(li):
    if (li[0]+li[1])/2>=90: return 1
    else: return 0

def a3(li):
    if sum(li)/3>=80: return 1
    else: return 0

def isA(li):
    if a1(li) or a2(li) or a3(li): return 1
    else: 0

def b1(li):
    if sum(li)/3>=70: return 1
    else: return 0

def b2(li):
    if sum(li)/3>=50 and (li[0]>=80 or li[1]>=80):
        return 1
    else: return 0

def isB(li):
    if b1(li) or b2(li): return 1
    else: 0

def isX(li):
    if isA(li):
        return 'A'
    elif isB(li):
        return 'B'
    else:
        return 'C'

while True:
    N=int(input())
    if N==0: break
    for _ in range(N):
        l=list(map(int,input().split()))
        print(isX(l))

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

    for _ in range(n):
        m, e, j = map(int, input().split())
        total = m + e + j
        if 100 in [m, e, j]:
            print("A")
        elif m + e >= 180:
            print("A")
        elif total >= 240:
            print("A")
        elif total >= 210:
            print("B")
        elif total >= 150 and (m >= 80 or e >= 80):
            print("B")
        else:
            print("C")

Python: # Aizu Problem 0218: Dividing Students

import sys, math, os, fractions

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def grade(m, e, j):
    if m + e >= 180 or m + e + j >= 240 or max(e, j, m) == 100:
        return 'A'
    elif m + e + j >= 210:
        return 'B'
    elif m + e + j >= 150 and max(m, e) >= 80:
        return 'B'
    return 'C'


while True:
    n = int(input())
    if n == 0:
        break
    for _ in range(n):
        m, e, j = [int(__) for __ in input().split()]
        print(grade(m, e, j))

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

Python: while(True):
    n = int(input())
    if not n: break
    for _ in range(n):
        m,e,j = map(int, input().split())
        if 100 in [m,e,j]: print("A"); continue
        elif (m+e)/2 >= 90: print("A"); continue
        elif (m+e+j)/3 >= 80: print("A"); continue
        elif (m+e+j)/3 >= 70: print("B"); continue
        elif (m+e+j)/3 >= 50 and (m>=80 or e>=80): print("B"); continue
        else: print("C"); continue

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

Python: while 1:
  n = int(input())
  if n == 0:
    break
    
  for _ in range(n):
    m, e, j = map(int, input().split())
    total = m + e + j
    if 100 in [m, e, j]:
      print('A')
    elif m + e >= 180:
      print('A')
    elif total >= 240:
      print('A')
    elif total >= 210:
      print('B')
    elif total >= 150 and (m >= 80 or e >= 80):
      print('B')
    else:
      print('C')

Python: def rank_a(m,e,j):
    if m == 100 or e == 100 or j==100:return True
    if (float(m) + e) /2 >= 90:return True
    if (float(m) + e + j) / 3 >= 80: return True

    return False

def rank_b(m,e,j):
    if (float(m) + e + j) / 3 >= 70: return True
    if (float(m) + e + j) / 3 >= 50 and \
        (m >= 80 or e >= 80):
            return True
while True:
    n = int(input())
    if n == 0: break
    for i in range(n):
        pm,pe,pj = list(map(int,input().split()))
        if rank_a(pm,pe,pj):
            print("A")
        elif rank_b(pm,pe,pj):
            print("B")
        else:
            print("C")

Python: while True:
    n = int(input())
    if n == 0:
        break
    for _ in range(n):
        p = list(map(int, input().split()))
        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")