#!/usr/bin/ruby
# -*- coding: utf-8 -*-

def calcCard(card)
  if card == 'A'
    11
  else
    card
  end
end

play = gets.to_i
play.times do
  hand = gets.split
  hand.push(gets.split).flatten!

  hand.map! {|ch|
    if ch == 'T' || ch == 'J' ||
       ch == 'Q' || ch == 'K'
      10
    elsif ch != 'A'
      ch.to_i
    else
      ch
    end
  }
  # p hand
  if (hand[0] == 10 && hand[1] == 'A') ||
     (hand[0] == 'A' && hand[1] == 10)
    puts "blackjack"
  else
    res = calcCard(hand[0]) + calcCard(hand[1])
    i = 1
    while true
      # p res
      if res <= 16
        i += 1
      elsif res == 17 && hand[0..i].include?("A")
        i += 1
      elsif res <= 21
        puts res
        break
      elsif hand[0..i].include?("A")
        ace = hand[0..i].find_index {|x| x == "A" }
        hand[ace] = 1
      else
        puts "bust"
        break
      end
      res = 0
      hand[0..i].each {|x| res += calcCard(x) }
    end
  end
end