Travel Plan (Large)

Visit every planet on a line exactly once and return to Earth, maximizing total travel distance without exceeding the fuel limit.

Hard8Dynamic programmingSortingMathNo attempts yetTime limit5sMemory limit512 MB

Problem

Antarctic astronomers have an observation they have not announced yet: space holds NN inhabited planets, and all of them lie on one straight line. The ii-th planet sits at coordinate XiX_i. Earth is the first planet and sits at coordinate 0, so X1=0X_1 = 0.

Excited by this, you plan a trip that visits all of them. Unknown planets are dangerous, so you leave Earth, visit each of the other planets exactly once, and return to Earth. You have FF units of fuel, and you want to burn as much of it as you can so that the final landing on Earth is safer. Your spaceship is basic. It flies in a straight line from a planet ii to another planet jj and burns XiXj|X_i - X_j| units of fuel on the way, and it cannot turn without landing.

Among the travel plans that burn at most FF units of fuel, find the one that burns the most, and print the amount of fuel it burns.

Input

The first line contains the number of test cases TT. Each test case takes three lines. The first line contains the number of planets NN. The second line contains the coordinates X1,X2,,XNX_1, X_2, \dots, X_N. The third line contains the amount of fuel FF that you have.

Limits

  • 1T201 \le T \le 20
  • 2N302 \le N \le 30
  • 1F10171 \le F \le 10^{17}
  • 1015Xi1015-10^{15} \le X_i \le 10^{15}
  • X1=0X_1 = 0
  • All XiX_i are different.

Output

For each test case, print one line. Print Case #x: NO SOLUTION when no such travel plan exists, and Case #x: y otherwise, where xx is the test case number starting from 1 and yy is the largest amount of fuel a plan burns.