Description
You are playing your favorite video game and have just entered a reward pass. In this reward Sekiri, the system will randomly throw k k times, each time you can choose to eat or not eat (must be thrown before the next treasure to make a choice, and now decide not to eat the treasures can not eat later). The treasure altogether has n n kinds, the system throws these n n kinds of treasures each time the probability is same and mutually independent. In other words, even if the former k−1 k-1 system all throw treasure 1 (This situation is likely to occur, although the probability is very small), the K K time to throw the probability of each treasure is still 1n \frac{1}{n}. Obtaining the first I species will get Pi p_i, but not every treasure is freely available. The first I species has a prerequisite for the collection of the precious Si s_i. Only when all the treasures in Si s_i have been eaten at least once can they eat the first I treasures (if the system throws a treasure that cannot be eaten at the moment, it loses an opportunity in vain). Note that Pi p_i can be negative, but if it is a prerequisite for many highly prized treasures, the loss of short-term benefits to eat this negative treasure will gain greater long-term benefits. Suppose you take
The optimal strategy, on average, how much you can score in the reward.
Input
The first behavior is two positive integers k K and n N, that is, the number and type of treasures.
The following n-N lines describe a treasure, in which the first integer represents the score,
The following integers, in turn, represent the various prerequisites for the artifact (each treasure number is 1 to n N), ending with 0.
1<=k<=100 1, 1<=n<=15 1, with a score of integers in [ -10^6,10^6].
Output
Outputs a real number that retains six decimal digits, i.e. the score of the average situation under the optimal strategy.
Sample Input
1 2
1 0
2 0
Sample Output
1.500000
HINT
train of thought
State compressed DP, set fi,s F_{i,s} to represent the former i−1 i-1 the type of the treasure before the binary s s when the value of the first I treasures, then can be solved, but there is a problem: sometimes S is not satisfied with the condition , this requires a lot of special sentences. Then another idea: Set Fi,s f_{i,s} to represent the former i−1