#P1948E. Clique Partition

    ID: 10350 Type: RemoteJudge 3000ms 512MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>binary searchconstructive algorithmsgraphsgreedy

Clique Partition

Description

You are given two integers, nn and kk. There is a graph on nn vertices, numbered from 11 to nn, which initially has no edges.

You have to assign each vertex an integer; let aia_i be the integer on the vertex ii. All aia_i should be distinct integers from 11 to nn.

After assigning integers, for every pair of vertices (i,j)(i, j), you add an edge between them if ij+aiajk|i - j| + |a_i - a_j| \le k.

Your goal is to create a graph which can be partitioned into the minimum possible (for the given values of nn and kk) number of cliques. Each vertex of the graph should belong to exactly one clique. Recall that a clique is a set of vertices such that every pair of vertices in it are connected with an edge.

Since BledDest hasn't really brushed his programming skills up, he can't solve the problem "given a graph, partition it into the minimum number of cliques". So we also ask you to print the partition itself.

The first line contains one integer tt (1t16001 \le t \le 1600) — the number of test cases.

Each test case consists of one line containing two integers nn and kk (2n402 \le n \le 40; 1k2n1 \le k \le 2n).

For each test case, print three lines:

  • the first line should contain nn distinct integers a1,a2,,ana_1, a_2, \dots, a_n (1ain1 \le a_i \le n) — the values you assign to the vertices;
  • the second line should contain one integer qq (1qn1 \le q \le n) — the number of cliques you partition the graph into;
  • the third line should contain nn integers c1,c2,,cnc_1, c_2, \dots, c_n (1ciq1 \le c_i \le q) — the partition of the graph into cliques. Where two vertices uu and vv are in the same clique if cu=cvc_u = c_v.

If there are multiple answers, print any of them.

Input

The first line contains one integer tt (1t16001 \le t \le 1600) — the number of test cases.

Each test case consists of one line containing two integers nn and kk (2n402 \le n \le 40; 1k2n1 \le k \le 2n).

Output

For each test case, print three lines:

  • the first line should contain nn distinct integers a1,a2,,ana_1, a_2, \dots, a_n (1ain1 \le a_i \le n) — the values you assign to the vertices;
  • the second line should contain one integer qq (1qn1 \le q \le n) — the number of cliques you partition the graph into;
  • the third line should contain nn integers c1,c2,,cnc_1, c_2, \dots, c_n (1ciq1 \le c_i \le q) — the partition of the graph into cliques. Where two vertices uu and vv are in the same clique if cu=cvc_u = c_v.

If there are multiple answers, print any of them.

Sample Input 1

3
2 3
5 4
8 16

Sample Output 1

2 1
1
1 1
3 1 5 2 4
2
1 1 2 1 2
1 2 3 4 5 6 7 8
1
1 1 1 1 1 1 1 1