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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#ifdef LOC
#include "debuglib.h"
#else
#define deb(...)
#define DBP(...)
#endif
using namespace std;
using   ll         = long long;
using   Vi         = vector<int>;
using   Pii        = pair<int, int>;
#define pb           push_back
#define mp           make_pair
#define x            first
#define y            second
#define rep(i, b, e) for (int i = (b); i < (e); i++)
#define each(a, x)   for (auto& a : (x))
#define all(x)       (x).begin(), (x).end()
#define sz(x)        int((x).size())

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cout << fixed << setprecision(10);

	int k; cin >> k;

	Vi pows;
	for (int i = k; i; i &= i-1) {
		pows.pb(__builtin_ctz(i)*2+2);
	}

	vector<Vi> G(61+sz(pows));

	G[2].pb(sz(G)-1);
	G[3].pb(sz(G)-1);
	G[60] = {58, 59};

	rep(i, 1, 29) {
		G[i*2+2] = {i*2, i*2+1};
		G[i*2+3] = {i*2, i*2+1};
	}

	int last = 1;
	G[1].pb(pows[0]);

	rep(i, 1, sz(pows)) {
		G[last].pb(60+i);
		last = 60+i;
		G[last].pb(pows[i]);
	}

	cout << sz(G)-1 << '\n';
	rep(i, 1, sz(G)) {
		assert(sz(G[i]) <= 2);
		each(v, G[i]) cout << v << ' ';
		rep(j, sz(G[i]), 2) cout << "-1 ";
		cout << '\n';
	}
	return 0;
}