fun main(args:Array<String>?): Unit {
    while(true){
        val n = readLine()!!.toInt()
        if (n == 0) return
        repeat(n){
            val (m, e, j) = readLine()!!.trim().split(' ').map(String::toInt)
            println(
                    when{
                        m == 100 || e == 100 || j == 100 -> 'A'
                        m + e >= 180 -> 'A'
                        m + e + j >= 240 -> 'A'
                        m + e + j >= 210 -> 'B'
                        m + e + j >= 150 && (m >= 80 || e >= 80) -> 'B'
                        else -> 'C'
                    }
            )
        }
    }
}
