import scala.math.{min,max}

object Main {
  val sc = new java.util.Scanner(System.in)
  def classify(p: Seq[Int]) = {
    if(p.max == 100 || p.take(2).sum >= 180 || p.sum >= 240) {
      "A"
    } else if(p.sum >= 210 || (p.sum >= 150 && p.take(2).max >= 80)) {
      "B"
    } else {
      "C"
    }
  }
  def main(args: Array[String]) {
    while(true) {
      val n = sc.nextInt
      if(n == 0) return

      for(_ <- 1 to n) {
        val p = Seq(sc.nextInt, sc.nextInt, sc.nextInt)
        println(classify(p))
      }
    }
  }
}