Under construction

Still being built. Things may change

Ito

Time limit1sMemory limit512 MB

Summary
Each valuable's next-year price is uniform between a and b, and each client wants the maximum expected money while keeping at least l in the worst case.
Level

Hard8 of 10

Topics
Geometry, Binary search, Sorting
Solved
No attempts yet

Problem

Math can be very interesting and fascinating, and it is no doubt worth a lifetime. But if you plan to spend your last days somewhere in the Caribbean, feeling warm sand under your feet and watching beautiful women bring you pina coladas one by one, you should find another use for your skills.

So Kiyoshi decided that his contribution to math was already great enough, and he would go make some money. As you have probably heard, an economic crisis is approaching quickly, and everyone wants an efficient way to save money. To follow the new market trends, Kiyoshi opened a consulting agency that helps clients invest their savings properly. Investment here has three simple steps: go to the market and buy some valuables, wait a year, then go back to the market and sell them.

There are NN different valuables available for investment. For each one, the current price cic_i wooddollars per measure unit is given. All valuables are unlimited in quantity and arbitrarily divisible, so you may buy any non-negative real amount of any valuable. For each valuable, two limits aia_i and bib_i are known. Next year, the cost of one measure unit will be continuously and uniformly distributed between these two values.

MM clients want Kiyoshi to create a good investment plan for each of them. The ii-th client has sis_i wooddollars. On one hand, each client wants to maximize the expected amount of money they will have after selling all valuables. On the other hand, they fear losing too much, so they want at least lil_i wooddollars in the worst case.

For each client, Kiyoshi needs to choose how much of each valuable the client should buy. The client can spend any amount of wooddollars, but no more than they own. Any unspent money is kept until next year. Tell each client the maximum expected sum of wooddollars they could have without risking too much.

Input

The first line contains two integers NN and MM (0≤N,M≤1000000 \leq N, M \leq 100000), the number of valuables and the number of clients.

The next NN lines describe the valuables. Each contains three integers cic_i, aia_i, and bib_i: the current cost of the valuable, and the limits aia_i and bib_i on its future cost (1≤ci≤1000001 \leq c_i \leq 100000, 0≤ai≤bi≤1000000 \leq a_i \leq b_i \leq 100000).

Then MM lines describe the clients. Each contains two integers sis_i and lil_i: the amount of money the client has, and the minimum amount the client accepts in the worst case (1≤li≤si≤1000001 \leq l_i \leq s_i \leq 100000).

Output

Print MM lines. The ii-th line contains one real number: the maximum expected amount of wooddollars the ii-th client could have without risking too much. An answer is accepted if its absolute or relative error does not exceed 10−610^{-6}. Formally, if your answer is AA and the jury's answer is BB, the checker accepts it when ∣A−B∣max⁡(1,B)≤10−6\frac{|A-B|}{\max(1,B)} \leq 10^{-6}.

Hint

In the example above, the first client buys 0.10.1 units of the second valuable and 99 units of the third. The second client buys 0.40.4 units of the first valuable, 0.30.3 units of the second, and 33 units of the third. The third client buys just 11 unit of the second valuable.

Examples1

  1. Example 1

    Input
    3 3
    10 5 31
    10 10 12
    1 0 5
    10 1
    10 5
    10 10
    
    Expected output
    23.6000000000
    18.0000000000
    11.0000000000