Space poker. A legendary game, the first version of which was introduced as far back as the year 1284 of the Alien era. Even nowadays, its rules are known only to a small group of professional players. Fortunately, the developers of the first program in the world to play space poker have asked for your help.
There are extraterrestrial players in space poker. At the beginning of the round, each player receives cards (we call them hole cards). Players do not know the hole cards of their opponents. Then, community cards are consecutively dealt face up. Thus, the community cards are visible to all players. A player's hand consists of their hole cards and all community cards — in total, M+K cards. There are no suits, and cards differ only in their values. There are different values: "2", "3", "4", , "9", "T", "J", "Q", "K" and "A". The deck is infinite, and the probability that the next card will have a given value is equal to .
Combinations in space poker take the form (v_1, \ldots, v_L), where is the number of different values in the combination. A hand satisfies the combination (v_1, \ldots, v_L) if it contains v_1 cards of one value, v_2 cards of another value, , v_L cards of the -th value. For example, the combination is satisfied by the hands "2JA2A" and "22233". The combination is satisfied by the hand "KQKQKQ", but not by the hand "AAAAAA". All combinations have different strengths.
The winner of the round is the player whose hand satisfies the combination of maximum strength among all those present in the hands of all players. If there is more than one such player, the round ends in a draw.
Suppose you know the hole cards of the first player and the community cards that have already been dealt. Calculate the probability that the first player will be the only winner of this round.
The first line contains integers , , and separated by spaces (2 \leq N, M \leq 10, 1 \leq K \leq 5). The second line contains symbols — the hole cards of the first player. The third line contains at most symbols — the community cards that have already been dealt. The fourth line contains integer — the number of combinations in space poker (1 \leq C \leq 100). Each of the next lines contains a combination description in order of increasing strength. Each description has the form L\ v_1\ v_2\ \ldots\ v_L. and v_i are positive integers, and the sum of all v_i does not exceed M+K.
Output the probability that the first player will win the round with absolute error not exceeding 10^{-5}.
მაგალითი 1