object Main extends App {
  import scala.io.StdIn._
  val n = readInt
  for (_ ← 0 until n){
    val Array(a, b) = readLine.trim.split(' ')
    println(
      solve(a, b, readLine.trim.split(' ').toList)
    )
  }

  def solve(a: String, b: String, deck: List[String]): String = {
    def take(deck: List[String], score: Int, hasAce: Int = 0): Int = {
      if (score <= 16) take(deck.tail, score + deck.head.asCard, hasAce + (if (deck.head == "A") 1 else 0))
      else if (score == 17 && hasAce > 0) take(deck.tail, score + deck.head.asCard, hasAce + (if (deck.head == "A") 1 else 0))
      else if (score > 21 && hasAce > 0) take(deck, score - 10, hasAce - 1)
      else score
    }
    if (a.asCard + b.asCard == 21) "blackjack"
    else take(deck, a.asCard + b.asCard, List(a, b).count(_ == "A")) match {
      case s if s <= 21 ⇒ s.toString
      case _ ⇒ "bust"
    }
  }

  implicit class WrappedChar(val value: String) extends AnyVal {
    def asCard: Int = if (value.head.isDigit) value.head.asDigit else if (value.head == 'A') 11 else 10
  }
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline
    def let[A](func: T ⇒ A): A = func(value)
    @inline
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
  }
}
