Fruits

Time limit: 1s Memory limit: 512MB Input: Output:

Task

You are given NN baskets. The ii-th basket contains AiA_i apples, BiB_i bananas and CiC_i cherries. Pick at most N+32\left\lfloor\frac{N+3}{2}\right\rfloor baskets in a way that you get at least half of each fruit.

One of the baskets..\text{One of the baskets.}.

It can be proven that there is always a solution. If there are multiple solutions, you can output any of them.

Input data

The first line of the input file contains a single integer TT, the number of test cases. TT test cases follow.

Each test case consists of:

  • a line containing integer NN, the number of baskets.
  • NN lines, the ii-th of which consisting of integers AiA_i, BiB_i, CiC_i, the number of apples, bananas, cherries in the ii-th basket.

Output data

The output file must contain 2T2 \cdot T lines, two lines for each test case. For each test case:

  • Print a single integer MN+32M \le \left\lfloor \frac{N+3}{2} \right\rfloor, the number of baskets you choose.
  • On the next line, print MM integers R0,R1,,RM1R_0, R_1, \dots, R_{M-1} -- the 0-based indices of the chosen baskets, separated by spaces.

Constraints and clarifications

  • 1T1 0001 \le T \le 1 \ 000.
  • 2N1 0002 \le N \le 1 \ 000. It is guaranteed that the sum of NN over all test cases does not exceed 1 000 0001 \ 000 \ 000.
  • 0Ai,Bi,Ci1 000 0000 \le A_i, B_i, C_i \le 1 \ 000 \ 000 for each i=0N1i=0\ldots N-1.
# Score Constraints
1 0 Examples
2 10 N15N \le 15, the sum of NN over all test cases does not exceed 1515
3 20 0Ai,Bi,Ci100 \le A_i, B_i, C_i \le 10 for each i=0N1i=0\ldots N-1. N100N \le 100, the sum of NN over all test cases does not exceed 100100
4 20 Ci=0C_i=0 for all i=0,1,,N1i=0,1,\ldots,N-1 (no cherries in the baskets)
5 50 No additional restrictions

Example 1

stdin

1
6
1 0 0
1 0 0
1 0 0
0 1 0
0 1 0
0 0 2

stdout

4
0 1 3 5

Explanation

In the first sample case, we need at least half of each fruit:

  • Apples \ge 2 \to pick at least 2 baskets from first 3 (1 0 0)
  • Bananas \ge 1 \to pick at least 1 basket from baskets 3-4 (0 1 0)
  • Cherries \ge 1 \to pick basket 5 (0 0 2)

Example 2

stdin

1
6
6 1 2
1 6 2
2 2 5
1 2 6
3 3 3
2 2 4

stdout

4
0 1 2 3

Log in or sign up to be able to send submissions!