ChatDOJ, Inc. wants to secure a whopping units of RAM to expand its AI services. However, amid fierce competition in AI, soaring chip prices and growing demand have made RAM difficult to obtain.
ChatDOJ, Inc. wants to compare contract terms from several suppliers to secure RAM in advance at the lowest possible cost.
There are companies that can supply RAM. Supplier initially has units of unused production capacity and offers the following two types of contracts, each of which may be signed any number of times.
Either type of contract reduces the supplier's remaining production capacity by the number of units contracted for. For example, signing an LTA when the remaining capacity is units secures units of RAM and leaves units of capacity.
A decrease in production capacity signals a supply shortage, so subsequent contract prices are not discounted even as the amount of RAM obtained through an LTA decreases. Each supplier's prices , remain fixed at their initial values, regardless of the number of contracts or the remaining capacity.
For each supplier, ChatDOJ, Inc. wants to find the minimum cost of contracting for exactly units of RAM from that supplier alone.
Each supplier's initial unused production capacity is at least units. Find the minimum cost for each supplier.
The first line contains the number of suppliers and the required number of units of RAM , separated by a space.
The next lines describe the suppliers. The -th of these lines contains supplier 's initial unused production capacity , LTA price , and individual contract price , separated by spaces.
For each supplier, print the minimum cost of contracting for exactly units of RAM, one per line in supplier order.
In the first example, the minimum cost for each supplier is as follows.
| 3 | 150 | No additional constraints. |
In the second example, supplier has only unit of capacity, so an LTA cannot secure any RAM and an individual contract is needed. Supplier can secure unit of RAM with one LTA. For supplier , signing an LTA first would secure more RAM than required, so an individual contract is needed.
In the third example, one LTA secures exactly units of RAM from any supplier. For each supplier, choose the smaller of the LTA price and the cost of individual contracts.