You are given n problems. The problems are of three types, 'Type1', 'Type2', and 'Type3'. There are t1 'Type1' problems, t2 'Type2' problems, and t3 'Type3' problems. You can solve each problem using any of the three methods, 'A', 'B', and 'C'. You can use a particular method only a limited number of times that is, method 'A' for a times, method 'B' for b times, and method 'C' for c times.
You are given a 3×3 matrix A where A[i][j] represents the effort to solve a Type i problem using Method j. You are required to find the minimum effort required to solve all the problems.
Input format
Output format
For each test case, print the minimum effort required to solve all the problems in a new line.
Constraints
1≤T≤51≤n≤1e9
0≤t1, t2, t3≤1e9 (sum of t1, t2, and t3 is equal to n)
0≤a, b, c≤1e9 (sum of a, b, and c is equal to n)
1≤A[i][j]≤1e9 (1≤i, j≤3)
For the only testcase, the optimal solution is -
Thus, total effort is 40+2+14=56.