CF2147B.Multiple Construction

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Multiple Construction

You are given an integer nn. Your task is to construct an array of length 2n2 \cdot n such that:

  • Each integer from 11 to nn appears exactly twice in the array.
  • For each integer xx (1xn1 \le x \le n), the distance between the two occurrences of xx is a multiple of xx. In other words, if pxp_x and qxq_x are the indices of the two occurrences of xx, qxpx| q_x - p_x | must be divisible by xx.

It can be shown that a solution always exists.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1041 \le t \le 10^4). The description of the test cases follows.

Each of the next tt lines contains a single integer nn (1n21051 \le n \le 2 \cdot 10^{5}).

It is guaranteed that the sum of nn over all test cases does not exceed 21052 \cdot 10^{5}.

Output

For each test case, print a line containing 2n2 \cdot n integers — the array that satisfies the given conditions.

If there are multiple valid answers, print any of them.

Note

Visualizer link

In the first test case:

  • The number 11 appears at positions 11 and 33: the distance is 22, which is divisible by 11.
  • The number 22 appears at positions 22 and 44: the distance is 22, which is divisible by 22.

In the second test case:

  • The number 11 appears at positions 11 and 33: the distance is 22, which is divisible by 11.
  • The number 22 appears at positions 44 and 66: the distance is 22, which is divisible by 22.
  • The number 33 appears at positions 22 and 55: the distance is 33, which is divisible by 33.

In the third test case, the two occurrences of 11 are at positions 11 and 22, so the distance between them is 11, which is a multiple of 11.

Samples

3
2
3
1
1 2 1 2
1 3 1 2 3 2
1 1

在线编程 IDE

建议全屏模式获得最佳体验