SP9753 TUPLEDIV - Tuple Division

Description

**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 i $ ^{th} $ group is C $ _{i} $ . We define the score of the i $ ^{th} $ group is the sum of value in the i $ ^{th} $ dimension of the tuples in the i $ ^{th} $ group. Your target is to firstly maximize the score of 1 $ ^{th} $ group, then maximize the score 2 $ ^{th} $ group and so on. **Input** The first line of the input contains an integer T(T **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

Input Format

N/A

Output Format

N/A