Equipment

No attempts yetTime limit5sMemory limit128 MB

Problem

A research institute has developed NN kinds of equipment for soldiers to wear. Each piece is rated in five categories: attack, defense, sight, portability, and ease of use. Every score is an integer between 00 and 1000010000 inclusive, so a piece of equipment is described by five integers.

A soldier wears exactly KK pieces of equipment. When several pieces are worn, each category improves independently by the maximum score in that category among the worn pieces. For example, if two pieces have sight scores 1010 and 1515, then wearing both improves sight by the maximum, 1515. This maximum is called the extended score of that category.

You want to choose exactly KK of the NN pieces so that the sum of the extended scores over the five categories is as large as possible. Find that maximum.

Let the scores of piece ii be (ri,1,ri,2,ri,3,ri,4,ri,5)(r_{i,1}, r_{i,2}, r_{i,3}, r_{i,4}, r_{i,5}) with 0ri,j100000 \le r_{i,j} \le 10000. If SS is the set of worn pieces, the goal is to maximize j=15maxiSri,j\sum_{j=1}^{5} \max_{i \in S} r_{i,j} subject to S=K|S| = K.

For example, let N=4N = 4, K=2K = 2, with the following scores.

  • Piece 1: (30,30,30,30,0)(30, 30, 30, 30, 0)
  • Piece 2: (50,0,0,0,0)(50, 0, 0, 0, 0)
  • Piece 3: (0,50,0,50,10)(0, 50, 0, 50, 10)
  • Piece 4: (0,0,50,0,20)(0, 0, 50, 0, 20)

Wearing pieces 1 and 3 gives an extended-score sum of 30+50+30+50+10=17030 + 50 + 30 + 50 + 10 = 170, which is the largest achievable value.

Input

The first line contains the number of test cases TT. For each test case, the first line contains two integers NN and KK (1N100001 \le N \le 10000, 1KN1 \le K \le N). Each of the following NN lines contains the scores of one piece of equipment as five space-separated integers ri,1r_{i,1}, ri,2r_{i,2}, ri,3r_{i,3}, ri,4r_{i,4}, ri,5r_{i,5}, each between 00 and 1000010000 inclusive.

Output

For each test case, print on its own line the maximum possible sum of extended scores when wearing KK of the NN pieces of equipment.