Upstairs and Downstairs

Konstantin must order at least K activities with capped repeats to minimize the chance Ilia falls asleep and later wakes.

Hard8ProbabilityGreedySortingNo attempts yetTime limit100sMemory limit512 MB

Problem

Konstantin and Ilia live in the same house. Konstantin lives upstairs and likes activities that involve jumping, moving furniture around and generally making noise. Ilia lives downstairs and likes to sleep.

To have a good evening, Konstantin wants to perform at least KK activities. Last night Ilia asked him to try not to wake him up, and Konstantin, who is a good neighbor, agreed. He took the request very literally, so he picks his activities to make the probability that Ilia wakes up after falling asleep as small as possible.

Activity ii has a probability ai/bia_i / b_i attached to it. When Konstantin performs it, Ilia is awake at the end of that activity with probability ai/bia_i / b_i and asleep otherwise. This outcome does not depend on whether Ilia was asleep when the activity started, and it is independent of the outcome of every other activity. Konstantin can perform activity ii at most cic_i times, because doing it more often is boring, and a bored Konstantin does not have a good evening.

Konstantin fixes an ordered sequence of activities so that:

  • the total number of activities is at least KK;
  • activity ii is performed no more than cic_i times;
  • the probability QQ that Ilia is woken up one or more times is as small as possible.

Ilia starts awake, so waking him up means that he is asleep at the end of some activity and awake at the end of the next one.

Konstantin cannot tell whether Ilia is awake or asleep, so he decides the whole sequence in advance and never adapts it while the evening goes on.

Find the smallest QQ Konstantin can achieve while still having a good evening.

Input

The first line contains the number of test cases TT. Each test case begins with a line holding two integers NN and KK. The next NN lines describe the activities Konstantin can choose from, one per line, in the format a/b c: the activity leaves Ilia awake with probability ai/bia_i / b_i, and Konstantin can perform it at most cic_i times. For example, 3/4 2 is an activity that leaves Ilia awake with probability 3/43/4 and can be performed at most twice.

Limits

  • 1T1001 \le T \le 100
  • 1N1041 \le N \le 10^4
  • 0aibi1060 \le a_i \le b_i \le 10^6, 1bi1 \le b_i, 1ci1 \le c_i
  • Let SS be the sum of all cic_i in one test case. Then 1KS1 \le K \le S and S106S \le 10^6.

Output

For each test case, print one line in the format Case #x: Q, where xx is the case number starting from 1 and QQ is the smallest probability that Ilia is woken up during the activities Konstantin performs.

Print QQ rounded to exactly nine digits after the decimal point. Every answer in the test data is far from a rounding boundary, so a double precision result printed with nine digits gives the expected line.