ParallelNetworkAnalysis
题号:NC202876
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
Special Judge, 64bit IO Format: %lld

题目描述

As an engineering student, Jack starts to consider a network problem. Jack designs a comparator circuit as the birthday present to Rose, which works by inputting two integers and outputting , the minimum of the two integers and , the maximum of the two integers.

Now Jack would like to build a comparator network which can sort integer permutations of size . This comparator network is divided into levels, where the -th level consists of n_i comparators and many wires. For the -th comparator of the -th level, you may choose two locations a_j, b_j, and this comparator will compare the two numbers from same locations of -th level and send the minimum of them to the location a_j and the maximum to the location b_j of the -th level. And in the last level the integers should be well sorted in ascending order from location to . Note that no two comparators in the same level can share the input from the same location.

When is very small, Jack easily constructs a comparator network based on bubbling sort, which is illustrated below.



But now he only has comparators, and he asks you to help him design a better parallel network meeting the requirements.

输入描述:

Only one integer  () --- the size of permutation.

输出描述:

Output one integer  in the first line --- the number of levels in this parallel network.
Then describe each level in order with the following format:
For each level, output one integer n_i in the first line --- the number of your comparator(s) in the -th level.
The following n_i lines describe comparators of this level, each contains two integers , satisfying , denoting that the -th and the -th number from the previous level are compared and the minimum is outputted to the a-th number of this level and the maximum the -th number.
It is required that any number should at most occurs once at the same level, and .
If there are multiple answers, output any of them.
If your answer does not meet the requirements or does not make the integer sequences in the evaluation data sorted correctly, you would receive a “Wrong Answer”.
示例1

输入

复制
4

输出

复制
5
1
0 1
1
1 2
2
0 1
2 3
1
1 2
1
0 1

说明

For the first test case, the figure is shown in the description above.
示例2

输入

复制
3

输出

复制
3
1
1 0
1
0 2
1
0 1