Flowers

Minimize W*pw + sum F_i*pf_i subject to W*vw_i + F_i*vf_i >= th_i, with W,F_i >= 0 and reals allowed.

Medium7MathGreedyGeometryNo attempts yetTime limit8sMemory limit512 MB

Problem

We planted NN flower seeds, and every seed grows into a different flower. We want all of them to bloom at the same time.

Every plant has a number called vitality, and it starts at 0. Watering and fertilizer change it, and plant ii blooms once its vitality is at least thith_i. Some flowers need no extra nutrition, so thith_i can be negative.

Water reaches every plant. Pouring WW liters of water changes the vitality of plant ii by W×vwiW \times vw_i for every ii (1iN1 \le i \le N) and costs W×pwW \times pw yen. WW does not have to be an integer. Some flowers hate water, so vwivw_i can be negative.

There are NN kinds of fertilizer, and the ii-th kind works only on plant ii. Spreading FiF_i kilograms of the ii-th fertilizer changes the vitality of plant ii by Fi×vfiF_i \times vf_i and costs Fi×pfiF_i \times pf_i yen. FiF_i does not have to be an integer either. Each fertilizer is made for its own plant, so vfivf_i is always positive.

Of course we also want to keep the total cost as small as possible. Formally, minimize

W×pw+i=1NFi×pfiW \times pw + \sum_{i=1}^{N} F_i \times pf_i

subject to W×vwi+Fi×vfithiW \times vw_i + F_i \times vf_i \ge th_i, W0W \ge 0 and Fi0F_i \ge 0 for every ii (1iN1 \le i \le N). Compute that minimum cost.

Input

The input holds several datasets. There are at most 100 of them, and the whole input is at most 20MB. One dataset is formatted like this.

N
pw
vw1 pf1 vf1 th1
:
:
vwN pfN vfN thN

The first line holds the number of flower seeds NN. The second line holds pwpw, the price of one liter of water. Each of the next NN lines describes one flower with four integers vwivw_i, pfipf_i, vfivf_i and thith_i, separated by a space.

Every value satisfies 1N1000001 \le N \le 100000, 1pw1001 \le pw \le 100, 100vwi100-100 \le vw_i \le 100, 1pfi1001 \le pf_i \le 100, 1vfi1001 \le vf_i \le 100 and 100thi100-100 \le th_i \le 100.

A line holding a single 0 marks the end of the input.

Output

For each dataset, print one line with the minimum cost that makes every flower bloom. Print the cost with exactly six digits after the decimal point, rounding the seventh digit and beyond half up.