1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <cstdio>
#include <vector>
using namespace std;

int main() {
	int i, j, k;
	scanf("%d", &k);
	vector<int> k_binarny;
	while (k > 0) {
		k_binarny.push_back(k % 2);
		k /= 2;
	}
	int n = k_binarny.size() * 2;
	vector<vector<int>> graf(n, vector<int>());
	for (i = 0; i < k_binarny.size() - 1; ++i) {
		graf[2 * i].push_back(2 * i + 1);
		graf[2 * i].push_back(2 * i + 2);
		graf[2 * i + 1].push_back(2 * i + 2);
	}
	for (i = 0; i < k_binarny.size() - 1; ++i)
		if (k_binarny[i])
			graf[2 * i + 1].push_back(n - 1);
	graf[n - 2].push_back(n - 1);
	printf("%d\n", n);
	for (i = 0; i < n; ++i) {
		for (j = 0; j < graf[i].size(); ++j)
			printf("%d ", graf[i][j] + 1);
		for (j = 0; j < 2 - graf[i].size(); ++j)
			printf("-1 ");
		printf("\n");
	}
		
	return 0;
}