n = gets.to_i
n.times do
  sum = 0
  eleven_num = 0
  k = 2
  gets.chomp.split.each do |c|
    if c =~ /[TJKQ]/
      sum += 10
    elsif c == ?A
      if eleven_num > 0
        sum += 1
      else
        sum += 11
        eleven_num += 1
      end
    else
      sum += c.to_i
    end
  end

  gets.chomp.split.each do |c|
    break if sum > 17
    break if sum == 17 && eleven_num == 0
    k += 1
    if c =~ /[TJKQ]/
      sum += 10
    elsif c == ?A
      if sum + 11 <= 21
        sum += 11
        eleven_num += 1
      else
        sum += 1
      end
    else
      sum += c.to_i
    end
    if sum > 21 && eleven_num > 0
      sum -= 10
      eleven_num -= 1
    end
  end

  if k == 2 && sum == 21
    puts 'blackjack'
  elsif sum > 21
    puts 'bust'
  else
    p sum
  end
end

