In the game of Blackjack, the player and the dealer are each dealt two cards to start. One of the dealer's cards is placed face up and is visible to the player, while the other is placed face down and is hidden. Given your two cards and the dealer's face-up card, compute the probability that your two-card hand is better than the dealer's two-card hand.
This is not simple: because cards are dealt from the decks without replacement, the probability changes as play proceeds. To keep things simple, we compute the probability only for the moment the cards are first dealt — that is, we assume no cards have been dealt from the decks beforehand.
Card values are as follows.
The value of an Ace is chosen so that the hand total is as large as possible without exceeding 21. For a two-card hand it is impossible for the total to exceed 21.
The player beats the dealer when both of the following hold.
Several decks may be used together. Each deck has 52 cards, with four each of A, K, Q, J, T, 9, …, 2.
The input consists of several test cases. The first line of each test case contains a positive integer $n$ ($n \le 10$), the number of decks used. The next line contains three characters, separated by spaces, from the set ${A, K, Q, J, T, 9, \dots, 2}$: the dealer's face-up card followed by your two cards, in that order. In each case, assume the $n$ decks have been shuffled together at random. The end of the input is marked by $n = 0$.
For each hand, print on a single line the probability of winning as a percentage, rounded to three decimal places and followed by a percent sign (%).