luogu#P12352. 「HCOI-R2」Rabbit Panic (Easy Ver.)

    ID: 11402 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>洛谷原创Special JudgeO2优化其它技巧构造洛谷月赛

「HCOI-R2」Rabbit Panic (Easy Ver.)

Background

Note that in this version of the problem, you don't need to minimize the number of operations, and the constraint of nn is different.

Problem Description

You have a sequence {pn}\{p_n\} where initially pi=i(1in)p_i = i(1 \leq i \leq n).

Each time you can choose mm distinct numbers i1,i2imi_1, i_2\dots i_m, and simultaneously set all of pi1,pi2pimp_{i_1}, p_{i_2}\dots p_{i_m} into their mean. Note that the mean may not be an integer. In this case, it will never be rounded.

You need to perform at most 2n22n^2 operations to make p1=p2==pnp_1 = p_2 = \dots = p_n. Note that in this version of the problem, you don't need to minimize the number of operations.

Input Format

Each test consists of multiple test cases. The first line contains a single integer T(1T104)T(1\leq T\leq 10^4) --- the number of sets of test cases. The description of each test case follows.

In each test case, the only line contains two integers --- nn(1n2×1031 \leq n \leq 2\times 10^3) and mm(1mn1\le m\le n), representing the length of the sequence and the number mm.

It's guaranteed that the sum of nn over all testcases does not exceed 10410^4.

Output Format

For each test case, on the first line, output the number of operations you perform, ss. You need to guarantee that s2n2s\le 2n^2.

On the next ss lines, each line contains mm distinct integers in the range [1,n][1, n] representing an operation.

If there's no solution, just print s=1s = -1.

If there are multiple solutions, print any. Note that you don't need to minimize the number of operations.

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

Hint

Sample #1

  • $[1,2,3,4,5,6]\to [3.5,3.5,3,4,3.5,3.5]\to [3.5,3.5,3.5,3.5,3.5,3.5]$。
  • There may be different but valid solutions.

Constraints

This problem uses subtasks.

  • Subtask 0 (20 pts): 1n101\leq \sum n\leq 10.
  • Subtask 1 (30 pts): mmod2=0m \bmod2 = 0.
  • Subtask 2 (10 pts): nmod2=0n \bmod 2 = 0 and mmod2=1m \bmod 2=1.
  • Subtask 3 (40 pts): No additional constraints.

It is guaranteed that 1T1031 \leq T \leq 10^3, 1mn2×1031 \leq m \leq n \leq 2\times 10^3, 1n1041 \leq \sum n \leq 10^4.