def score(card)
  ace = 0
  min = 0
  max = 0
  card.each do |c|
    case c
    when "A"
      min += 1
      ace += 1
    when "2".."9"
      min += c.ord - "0".ord
    else
      min += 10
    end
  end
  max = min
  use = 0
  ace.times do
    if max + 10 <= 21
      max += 10
      use += 1
    end
  end
  [min, max, use]
end

n = gets.to_i
n.times do
  hand = Array.new
  hand = gets.split
  card = gets.split
  case score(hand)[1]
  when 21
    puts "blackjack"
  when 0..20
    card.each do |c|
      case score(hand)[1]
      when 0..16
        hand.push(c)
      when 17
        hand.push(c) if score(hand)[2] > 0
      else
        break
      end
    end
    if score(hand)[0] > 21
      puts "bust"
    elsif score(hand)[1] <= 21
      puts score(hand)[1]
    else
      puts score(hand)[0]
    end
  else
    puts "bust"
  end
end