OC Rahman is notorious for accepting bribes. Influential people in his area now seek to bribe him to handle their issues. Despite OC Rahman's recent commitment to improving his behavior by reducing bribery and unethical actions.
Suppose there are days and powerful individuals. For each of the days, OC Rahman gets a new offer from every powerful individual. OC Rahman starts taking bribes from the first day.
He can complete task of any person on any day On the day, the person offers OC Rahman a certain amount of money represented by If OC Rahman completes the task assigned by a person on that day, he receives the corresponding amount. However, if OC Rahman completes the task for the person on the day, on the next day, all individuals except for the person will offer an additional amount of money, denoted by in addition to their initial offer. No additional money will be applied for any tasks assigned on the first day. Please note that OC Rahman will exactly complete one task per day.
OC Rahman, having reliable sources, gathers information about the daily offers he will receive from each person, as well as the additional amount they will offer. Assist OC Rahman in minimizing the bribes he accepts.
The first line will be a single integer indicating the number of test cases. For each test case the first line will contain three integers separated by space indicating the number of days and the number of power full people and the number of extra amounts.
Following lines each line containing integers each indicating the amount offered on the day by the person.
lines each line representing OC Rahman’s minimum bribe collection.
Input | Output |
---|---|
3 2 2 100 1 3 7 1 3 2 2 1 7 7 1 1 5 3 3 2 1 7 7 2 1 5 1 6 6 | 4 7 4 |