CF2106B.St. Chroma

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

St. Chroma

Given a permutation^{\text{∗}} pp of length nn that contains every integer from 00 to n1n-1 and a strip of nn cells, St. Chroma will paint the ii-th cell of the strip in the color MEX(p1,p2,...,pi)\operatorname{MEX}(p_1, p_2, ..., p_i)^{\text{†}}.

For example, suppose p=[1,0,3,2]p = [1, 0, 3, 2]. Then, St. Chroma will paint the cells of the strip in the following way: [0,2,2,4][0, 2, 2, 4].

You have been given two integers nn and xx. Because St. Chroma loves color xx, construct a permutation pp such that the number of cells in the strip that are painted color xx is maximized.

^{\text{∗}}A permutation of length nn is a sequence of nn elements that contains every integer from 00 to n1n-1 exactly once. For example, [0,3,1,2][0, 3, 1, 2] is a permutation, but [1,2,0,1][1, 2, 0, 1] isn't since 11 appears twice, and [1,3,2][1, 3, 2] isn't since 00 does not appear at all.

^{\text{†}}The MEX\operatorname{MEX} of a sequence is defined as the first non-negative integer that does not appear in it. For example, MEX(1,3,0,2)=4\operatorname{MEX}(1, 3, 0, 2) = 4, and MEX(3,1,2)=0\operatorname{MEX}(3, 1, 2) = 0.

Input

The first line of the input contains a single integer tt (1t40001 \le t \le 4000) — the number of test cases.

The only line of each test case contains two integers nn and xx (1n21051 \le n \le 2 \cdot 10^5, 0xn0 \le x \le n) — the number of cells and the color you want to maximize.

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

Output

Output a permutation pp of length nn such that the number of cells in the strip that are painted color xx is maximized. If there exist multiple such permutations, output any of them.

Note

The first example is explained in the statement. It can be shown that 22 is the maximum amount of cells that can be painted in color 22. Note that another correct answer would be the permutation [0,1,3,2][0, 1, 3, 2].

In the second example, the permutation gives the coloring [0,0,0,4][0, 0, 0, 4], so 33 cells are painted in color 00, which can be shown to be maximum.

Samples

7
4 2
4 0
5 0
1 1
3 3
1 0
4 3
1 0 3 2
2 3 1 0
3 2 4 1 0
0
0 2 1
0
1 2 0 3

在线编程 IDE

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