Space Emergency (Large)

Choose up to L stars for speed boosters on a route with repeating leg lengths so the flagship reaches the last star as early as possible.

Medium7GreedySortingMathNo attempts yetTime limit5sMemory limit512 MB

Problem

There is an emergency in space. You have to send your fleet's flagship from star 00 to star NN as quickly as possible, passing through the stars in increasing order along the way (01N0 \to 1 \to \dots \to N). The flagship normally travels at 0.50.5 parsecs per hour.

Apart from sending the flagship, you can order your engineers to build up to LL speed boosters, each on a different star. Building one booster takes tt hours, and all LL of them start at time 00, so every booster is finished at time tt. While the flagship travels from a star with a finished booster to the next star, its speed is 11 parsec per hour.

If the booster on a star is finished while the flagship is traveling from that star to the next one, the flagship speeds up the moment the booster is finished.

You build the boosters so that the flagship arrives as early as possible. How many hours does it take the flagship to reach star NN?

Input

The first line contains the number of test cases TT. Each of the next TT lines contains the integers LL, tt, NN, CC, followed by CC integers a0,,aC1a_0, \dots, a_{C-1}, all separated by spaces. For every integer kk, aia_i is the distance in parsecs between star k×C+ik \times C + i and star k×C+i+1k \times C + i + 1.

For example, with N=8N = 8, C=3C = 3, a0=3a_0 = 3, a1=5a_1 = 5 and a2=4a_2 = 4, the distances between consecutive stars are [3,5,4,3,5,4,3,5][3, 5, 4, 3, 5, 4, 3, 5].

Constraints

  • 1T1001 \le T \le 100
  • 1C10001 \le C \le 1000
  • CN106C \le N \le 10^6
  • 1ai1041 \le a_i \le 10^4
  • 0t10110 \le t \le 10^{11}, and tt is even
  • 0LN0 \le L \le N

Output

For each test case, print one line in the form "Case #x: y", where xx is the test case number starting from 11 and yy is the number of hours it takes to reach star NN. The answer is always an integer.

Note

In the second test case of the first sample you can build one booster, and the distances between consecutive stars are [10,4][10, 4]. Build the booster on star 00. After 44 hours the flagship has covered 22 parsecs and the booster is finished. The remaining 88 parsecs take 88 more hours, so the flagship reaches star 11 at hour 1212, and 88 more hours bring it to star 22, the destination.

In the universe of this problem the speed of light is much higher than 11 parsec per hour, so special relativistic effects do not matter.