Airport Walkways (Large)

Allocate up to t seconds of running between walkway and plain corridor segments to reach point X in minimum time.

Medium6GreedySortingMathNo attempts yetTime limit5sMemory limit512 MB

Problem

You are in an airport, standing at point 0. A corridor of length XX leads to your gate. The corridor contains moving walkways, and walkway ii moves toward the gate at speed wiw_i. While you walk or run on that walkway, your speed is your own speed plus wiw_i. The walkways never change position; they only carry you faster. The walkways do not overlap: at most one walkway covers any point of the corridor, but one walkway may begin exactly where another ends.

Your normal walking speed is SS. You are worried about missing the plane, so you can also run. You run at speed RR, for at most tt seconds in total. The tt seconds do not have to be consecutive. You may split them into any number of intervals, and you may leave part of them unused.

Decide when to walk and when to run so that you reach point XX as early as possible, and report that time.

Input

The first line contains the number of test cases, TT. TT test cases follow.

The first line of each test case contains five integers XX, SS, RR, tt and NN: the length of the corridor in meters, your walking speed in meters per second, your running speed in meters per second, the total time in seconds you are allowed to run, and the number of walkways.

Each of the next NN lines contains three integers BiB_i, EiE_i and wiw_i: the beginning and the end of the walkway in meters from your starting point, and the speed of the walkway in meters per second. The walkways are given in increasing order of beginning position.

Limits

  • 1T401 \le T \le 40
  • 1S<R1001 \le S < R \le 100
  • 1wi1001 \le w_i \le 100
  • 0Bi<EiX0 \le B_i < E_i \le X
  • EiBi+1E_i \le B_{i+1}
  • 1t1061 \le t \le 10^6
  • 1X1061 \le X \le 10^6
  • 1N10001 \le N \le 1000

Output

For each test case, print one line of the form Case #x: y, where xx is the test case number starting from 1 and yy is the shortest time in seconds needed to reach point XX.

Round yy at the sixth digit after the decimal point and print exactly six digits after the point, so a small value still prints as 4.000000. Every answer in the test data sits far from a rounding boundary, so the rounding direction is never in doubt.

Hint

In the first example case, the best plan is to start running immediately and run for one second.