Wile E. Coyote is back. He is back in the business. The business of capturing the road runner. Being the most loyal customer to the Acme Corporation, they are hoping to do some great business with him. Al- though, Acme makes literally every kinds of devices, all of them has a similarity, that has been kept se- cret for ages. All of their products use a secret ele- ment “element X” (this is kept so secret that, only you and the Acme people know about this). The decision makers of the Acme Corp. has already estimated the maximum amount of element X that can be used into manufacture every month. For month i, the per unit manufacturing cost of “element X” is mi, and at most ni units can be pro- duced. Moreover, the selling price for “element X” for that month is pi. One more thing is that, element X older than Ei months can not be used. But good thing is that, they can store any amount of element X in their inventory (it’s the Acme Corp, they can make anything :) ). Now, Acme Corporation wants to know how much element X should be produced and sold, to make the highest amount of profit. Input • First line contains T, the number of test cases. • For each test case – First line contains two integers M and I, the number of months to consider and the cost of storing per unit of element X per month in the inventory. – Each of the next M lines describe the parameters for each month ∗ The i-th line contains 5 integers, mi, ni, pi, si, Ei, where mi is the per unit manufacturing cost for month i, ni is the maximum amount that can be manufactured in this month, pi is the selling price for that month (per unit), si is the maximum amount that can be sold that month, and Ei is the maximum time, element X manufactured on month i, can be stored in the inventory. For example, if for month 1, E1 = 3, the elements produced inmonth1canbesoldinmonths1,2,3and4. Butitcannotbesoldinmonth5. Output For each test case, output the case number and the maximum amount of profit, Acme Corporation can make. Note that, you have to think of only M months. If any amount of element X is stored in the inventory after this period, are completely ignored. For formatting, see the sample input and output. Constraints
2/2 • T ≤ 100 • M ≤ 100 • 0 ≤ I,mi,ni,pi,si ≤ 106 • 0≤Ei ≤M Sample Input 1 22 2 10 3 20 2 10 100 7 5 2 Sample Input Case 1: 20