

Food ProblemTime Limit: 3000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1810 Accepted Submission(s): 568 Problem Description Few days before a game of orienteering, Bell came to a mathematician to solve a big problem. Bell is preparing the dessert for the game. There are several different types of desserts such as small cookies, little grasshoppers and tiny mantises. Every type of dessert may provide different amounts of energy, and they all take up different size of space. Other than obtaining the desserts, Bell also needs to consider moving them to the game arena. Different trucks may carry different amounts of desserts in size and of course they have different costs. However, you may split a single dessert into several parts and put them on different trucks, then assemble the parts at the game arena. Note that a dessert does not provide any energy if some part of it is missing. Bell wants to know how much would it cost at least to provide desserts of a total energy of $p$ (most of the desserts are not bought with money, so we assume obtaining the desserts costs no money, only the cost of transportation should be considered). Unfortunately the mathematician is having trouble with her stomach, so this problem is left to you. Input The first line of input contains a integer $T (T \leq 10)$ representing the number of test cases. For each test case there are three integers $n, m, p$ on the first line $(1 \leq n \leq 200, 1 \leq m \leq 200, 0 \leq p \leq 50000)$, representing the number of different desserts, the number of different trucks and the least energy required respectively. The $ith$ of the $n$ following lines contains three integers $t_i, u_i, v_i (1 \leq t_i \leq 100, 1 \leq u_i \leq 100, 1 \leq v_i \leq 100)$ indicating that the $ith$ dessert can provide $t_i$ energy, takes up space of size $u_i$ and that Bell can prepare at most $v_i$ of them. On each of the next $m$ lines, there are also three integers $x_j , y_j , z_j (1 \leq x_j \leq 100, 1 \leq y_j \leq 100, 1 \leq z_j \leq 100)$ indicating that the $jth$ truck can carry at most size of $x_j$ , hiring each one costs $y_j$ and that Bell can hire at most $z_j$ of them. Output For every test case output the minimum cost to provide the dessert of enough energy in the game arena if it is possible and its cost is no more than $50000$. Otherwise, output $TAT$ on the line instead. Sample Input
Sample Output
Source  
