Byte Me!

No attempts yetTime limit1sMemory limit128 MB

Problem

You are a dealer at The One, the first all-binary casino in Las Vegas. The blackjack tables there do not use cards. They use bytes, an 8-bit sequence representing a number from 0 to 255, and nibbles, a 4-bit sequence representing a number from 0 to 15.

All day long you play the house's hand against one opponent after another. The owners know their statistics, and the strategy they handed you leaves gamblers with slightly worse than even odds.

Here are the rules of binary blackjack:

  1. The goal of the game is to be the player closest to 510 points without going over.
  2. Each player is dealt two bytes, one face up and one face down.
  3. A player may then take more bytes by saying Byte Me!, or more nibbles by saying Nibble Me!, until he reaches his limit of 4 hits or has more than 510 points showing.
  4. All hits are played face up.
  5. A player who goes over 510 busts immediately and loses the hand.
  6. The dealer hits last.
  7. The dealer wins any tie, including a tie where everyone busts.

The dealer follows these rules, listed in order of precedence, where a lower numbered rule overrides a higher numbered one:

  1. Never hit when it is certain that you have won, judging only from your own hand and from what is showing in the other hands.
  2. If your total is strictly less than 382, take a byte hit.
  3. If your total is at most 500, take a nibble hit.
  4. Take no hits.

Rule 1 turns on what the dealer can see: his own two cards, and one face-up card for each other player. Every card he cannot see is a byte, so its value is somewhere from 0 to 255. The dealer is certain he has won only when no filling of those unseen cards puts any player's total above his own.

Input

The input is a non-empty series of at most 100 data sets. No blank line separates data sets.

A single data set has 6 components:

  1. Start line. A single line START N, where N is the number of players playing this hand, not counting the dealer. There are never more than 10 non-dealer players, and the dealer never plays by himself.
  2. Dealer line. A single line containing 2 binary strings of exactly eight digits, separated by exactly one space. These two strings are the two cards in the dealer's hand.
  3. Player line. A single line containing N 8-digit binary strings, each separated from the others by a single space. These are the face-up cards of all the non-dealer players.
  4. Byte line. A single line containing 4 8-digit binary strings, each separated from the others by a single space. These are the next 4 bytes in the byte deck, in the order they will be drawn.
  5. Nibble line. A single line containing 4 4-digit binary strings, each separated from the others by a single space. These are the next 4 nibbles in the nibble deck, in the order they will be drawn.
  6. End line. A single line END.

A single line ENDOFINPUT follows the final data set.

Two more facts are worth knowing:

  • Every non-dealer player is dealt the face-down card 11111111, value 255. The dealer has no knowledge of this.
  • Players other than the dealer never hit. They are not too bright.

Output

Report the actions the dealer takes and how the dealer fares with the resulting hand.

For each data set print exactly one output set, made of these components:

  1. Hand line. A single line HAND N, where N is the number of players playing this hand, not counting the dealer.
  2. Dealer hit list. One line for each hit the dealer takes on his turn. Print Byte me! for a byte hit and Nibble me! for a nibble hit.
  3. Outcome line. A single line containing Win! if the dealer wins, Bust! if the dealer loses by busting, and Lose! if the dealer loses without busting.