There are N shops each selling M different kinds of items. The ith store sells the jth item for Cij dollars. You decide to buy M−1 different type of items from each shop. If you want to have all M kinds of items in your shopping bag, then what is the minimum amount that you need to spend?
Input format
Output format
For each test case, print the minimum cost required as described in the problem statement in a new line. Print -1 if it is not possible to have all M different kinds of items.
Constraints
1 ≤ T ≤ 10
1 ≤ N ≤ 1000
1 ≤ M ≤ 1000
1 ≤ Cij ≤ 109
We can buy 1st and 2nd items from shop 01, 2nd and 3rd item from shop 02 and 1st and 2nd items from shop 03.
Hence the total sum is (2 + 3) + (2 + 5) + (4 + 4) = 5 + 7 + 8 = 20 dollars