SP15061 GCJ102B - World Cup 2010

Description

N/A

Input Format

The first line of the input gives the number of test cases, **T**. **T** test cases follow. Each case starts with a line containing a single integer **P**. The next line contains 2 $ ^{P} $ integers -- the constraints `M[0]`, ..., `M[2 $ ^{P} $ -1]`. The following block of **P** lines contains the ticket prices for all matches: the first line of the block contains 2 $ ^{P-1} $ integers -- ticket prices for first round matches, the second line of the block contains 2 $ ^{P-2} $ integers -- ticket prices for second round matches, etc. The last of the **P** lines contains a single integer -- ticket price for the final match of the World Cup. The prices are listed in the order the matches are played.

Output Format

For each test case, output one line containing "Case #x: y", where x is the case number (starting from 1) and y is the minimal amount of money Varva needs to spend on tickets as described above.