spoj#TUPLEDIV. Tuple Division

Tuple Division

Description

You are given N tuples with M dimensions. You need to choose some tuples and divide them into M groups. Each tuple can be used for only once and the size of the ith group is Ci. We define the score of the ith group is the sum of value in the ith dimension of the tuples in the ith group. Your target is to firstly maximize the score of 1th group, then maximize the score 2th group and so on. 

Input

The first line of the input contains an integer T(T≤50), indicating the number of cases. Each case begins with two integer N(1≤N≤10000) and M(1≤M≤10), the number of tuples and the number of groups. Then there is one line contain M integers. The ith integer Ci (Ci >=0, sigma Ci <= N) represents the size of the ith group. Then N lines with M integers follow. Each of them describes a tuple. The jth integer on the ith line Tij (0 <=Tij <= 10000) denotes the value of the jth dimension of the ith tuple.

Output

For each test case, print one line with M score of some optimal division.

Sample Input

2

4 2

2 1

3 2

2 1

2 2

1 1

4 3

1 1 2

8 7 1

8 7 2

8 7 4

8 2 3

Sample Output

5 2

8 7 7

Hint

In case 2, we can dive the group like:

Group 1: (8, 7, 2)  score = 8

Group 2: (8, 7, 1)  score = 7

Group 3: (8, 7, 4), (8, 2, 3) score = 4 + 3 = 7