F. Clique Partition

内存限制
512 MiB
时间限制
2000 ms
标准输入输出
题目类型
传统
评测方式
无测试数据
上传者 admin
题目来源 codeforces

题目描述

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

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

After assigning integers, for every pair of vertices , you add an edge between them if .

Your goal is to create a graph which can be partitioned into the minimum possible (for the given values of and ) 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 ( ) — the number of test cases.

Each test case consists of one line containing two integers and ( ; ).

输出格式

For each test case, print three lines:

  • the first line should contain distinct integers ( ) — the values you assign to the vertices;
  • the second line should contain one integer ( ) — the number of cliques you partition the graph into;
  • the third line should contain integers ( ) — the partition of the graph into cliques. Where two vertices and are in the same clique if .

If there are multiple answers, print any of them.

样例

输入 #1

3
2 3
5 4
8 16

输出 #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