n=gets.to_i
hash = {"A"=>11,"2"=>2,"3"=>3,"4"=>4,"5"=>5,"6"=>6,"7"=>7,"8"=>8,"9"=>9,"Q"=>10,"K"=>10,"T"=>10,"J"=>10}
n.times do
  hand=0
  a,b = gets.chomp.split
  ace=0
  if a=="A"|| b=="A"
    ace=1
  end
  hand+=hash[a]
  hand+=hash[b]
  if hand==21
    puts "blackjack"
    gets
    next
  elsif hand==22
    hand -=10
    ace-=1
  end
  deck = gets.chomp.split
  deck.each do |x|
    if hand <= 16 || hand ==17 && ace>0
      if x=="A"
        ace+=1
      end
      hand+=hash[x]
      if hand>21
        if ace >0
          ace-=1
          hand-=10
        else
          puts "bust"
          break
        end
      end
    else
      puts hand
      break
    end
  end
end