Poker

Time Limit: 2000ms
Memory Limit: 102400KB
This problem will be judged on HDU. Original ID: 5460
64-bit integer IO format: %I64d      Java class name: Main

Description

Given $N$ cards in poker and an integer $Q$. Choose several cards and form an expression, whose result equals to $Q$, via addition, subtraction, multiplication and division. Each expression, which meet the requirements, with $x$ cards can earn $x^2$ points. The intermediate value for each step must be an non-negative integer.

You need to calculate how many points you can get. Your attention, two expressions are different if and only if the prefix expressions of them are different. In others words, if an expression can transform to another through commutative law or associative law, these two expressions are considered distinct.

Moreover, two cards with the same number are also viewed different.

Input

There is one integer $T~(1<T\le 13)$ in the beginning of input, which means that you need to process $T$ test cases. In each test case, two integers $N~(1<N\le 8)$ and $Q~(0\le Q\le 32)$, as the problem described above, are shown in the first line. And in the second line are $N$ integers $A_i~(1\le A_i\le 13)$, indicating $N$ numbers on the cards.

You may assume that there are at most two test case containing $N=8$.

Output

For each test case, you should print one non-negative integer as the total points you can get, in a line.

Sample Input

2
3 12
3 3 4
3 12
9 5 3

Sample Output

Case #1: 16
Case #2: 26

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .