Puzzle: A classic composition of the cost flow, we think that this point is at the other end of the point, but only by another point of influence. So this composition is ingenious, because N is not big, so we can put the computer repair of the people to the nn point, each point is the bottom of the number of customers to repair. Then everyone imagine, for example, I was the first to repair the computer, I am now the penultimate to find this person, then I only affect the one behind me and myself, so to fix a fee for tij*2tij∗2, flow of 1 1 side flow over the past is good. may have not understood the oneself to have a good reason, then each split point directly connects to the meeting point. The front is the beginning of the connection to each customer, and then repair the computer to each of the split, when the flow is full of the flow of every customer to do is finished, of course, this is also guaranteed accuracy, because the time is positive, so the narrowing of the flow will ensure that in everyone from the flow of small is the last of the first to stay
。
Jam ' s store Accepts:15 submissions:42 time limit:2000/1000 MS (java/others) Memory limit:65536/65536 K (java/others) Problem description
Jam do not study hard, and then go to help others repair computer, in a shop, there are mm shop assistants, now have nn customers, give each customer corresponding to each clerk's repair computer time for t_{ij}t IJ, ask all customers to wait for the least time. Of course, when a customer finishes at a clerk, the clerk will perform the next customer's task.
Enter a description
The first line T (1 \leq t \leq) t (1≤t≤100), which represents the TT group data.
Next the TT Group data:
The first behavior of each group of data m,n (1 \leq m,n \leq) m,n (1≤m,n≤20) represents the number of clerks and customers
the next NN line mm column, each integer represents the time of the second customer to find the first JJ clerk (1 \ Leq T_{ij} \leq 1000) (1≤t ij≤1000)
Output description
Outputs a number that indicates the total time elapsed
Input sample
1
4 3
4 4 1 5
8 2 5 6
4 5 10 5
Output sample
7
Hint
1th Customer Select 3rd Employee
2nd Customer Select 2nd Employee
3rd Customer Select 1th Employee Total
cost 4+2+1=7