Buddy, Can You Spare a Tronk?

No attempts yetTime limit5sMemory limit128 MB

Problem

The principal unit of currency in the world of Tron is the Tronk. Making change for a Tronk is surprisingly tricky. In the USA we have half-dollars, quarters, dimes, nickels, and pennies, worth respectively $\frac{1}{2}$, $\frac{1}{4}$, $\frac{1}{10}$, $\frac{1}{20}$, and $\frac{1}{100}$ of a dollar. In the world of Tron there are infinitely many coins, one for the reciprocal of every positive integer:

$$1,\ \frac{1}{2},\ \frac{1}{3},\ \frac{1}{4},\ \frac{1}{5},\ \dots$$

In particular, there is no smallest coin.

Using a combination of exactly $n$ coins, how many different ways are there to make change for one Tronk — that is, to choose $n$ unit fractions whose sum is exactly $1$? For example, with $n = 3$ coins there are exactly three ways:

$$\frac{1}{3}+\frac{1}{3}+\frac{1}{3},\qquad \frac{1}{2}+\frac{1}{3}+\frac{1}{6},\qquad \frac{1}{2}+\frac{1}{4}+\frac{1}{4}.$$

Two extra constraints apply:

  • You are given an integer $r$. No coin may be used more than $r$ times. For example, if $r = 2$ the first combination above is no longer valid, but the other two still are. If $r = 0$, each coin may be used any number of times.
  • You are given a list of integers $F = {f_1, f_2, \dots, f_k}$. None of the reciprocals $\frac{1}{f_i}$ may be used. For example, if $F = {4, 6}$ then $\frac{1}{4}$ and $\frac{1}{6}$ are forbidden, so only the first combination above remains valid.

Every combination you report must be exact. Because of floating-point error and extremely small coins (such as $\frac{1}{10000000}$), a set of coins can sum to a value arbitrarily close to $1$; if it does not sum to exactly $1$, it is wrong.

Input

The first line contains the number of test cases $T$ ($T \le 20$). Each of the next $T$ lines describes one test case and lists, in order:

  • $n$ — the exact number of coins that must be used ($n \le 10$);
  • $r$ — the repetition limit ($r = 0$ means each coin may be used any number of times);
  • $k$ — the number of forbidden coins ($k \le 20$);
  • $f_1, f_2, \dots, f_k$ — the forbidden coins.

You may assume that no valid combination ever needs a coin smaller than $\frac{1}{10000000}$; equivalently, every denominator that can appear is at most $10{,}000{,}000$.

Output

For each test case, print the results in the following format.

First print a header line:

Case i : Number of coins = n; Repetitions = r; Forbidden = [f_1 f_2 ... f_k]

Here $i$ is the test-case number starting from $1$, and the forbidden coins are listed in the order they were given (use empty brackets [] when there are none).

Then print every valid combination on its own line. Within a line, list the coin denominators separated by single spaces and in non-decreasing order; for instance the set ${\frac{1}{6}, \frac{1}{3}, \frac{1}{2}}$ is written as 2 3 6. The combinations must appear in lexicographically increasing order (compare the denominator sequences element by element).

Finally print the line C solutions found, where $C$ is the number of valid combinations. If there are none, print No solutions found instead, with no combination lines.