require 'scanf'

def cond1(math,eng,jpn)
    return 2 if math==100 or eng==100 or jpn==100
    return 0 
end
def cond2(math,eng,jpn)
    return 2 if math+eng>=90*2
    return 0 
end
def cond3(math,eng,jpn)
    return 2 if math+eng+jpn>=80*3
    return 0
end
def cond4(math,eng,jpn)
    return 1 if math+eng+jpn>=70*3
    return 0
end
def cond5(math,eng,jpn)
    return 1 if math+eng+jpn>=50*3 and (math>=80 or eng>=80)
    return 0 
end

while true
    n = STDIN.gets.to_i
    exit 0 if n==0
    for i in 0..n-1 do
        math,eng,jpn=STDIN.gets.scanf("%d %d %d")
        conds =  cond1(math,eng,jpn) + cond2(math,eng,jpn) + cond3(math,eng,jpn) + cond4(math,eng,jpn)  + cond5(math,eng,jpn)
        print "A\n" if conds >= 2
        print "B\n" if conds == 1
        print "C\n" if conds == 0
    end
end