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
62
63
64
65
66
67
68
69
70
71
72
73
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define REP(i,n) for(int _n=(n), i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define TRACE(x) cerr << "TRACE(" #x ")" << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << endl;
typedef long long LL; typedef unsigned long long ULL;


#define BIGMOD 1000012177LL

vector<vector<int> > solve(int n)
{
    vector<vector<int> > dag;
    const int maksymalnyNumerWierzcholka = 100;
    dag.emplace_back(vector<int>());
    for (int i=1; i <= maksymalnyNumerWierzcholka; i++)
    {
        dag.emplace_back(vector<int>());
    }
    int right = maksymalnyNumerWierzcholka; //
    for (int i=16; i <= 46; i++)
    {
        int g = i*2;
        int cross = i*2 + 1;

        dag[g].emplace_back(right);
        dag[cross].emplace_back(g);
        dag[cross].emplace_back(right);
        right = cross;
    }
    for (int i=1; i <= 30; i++)
    {
        dag[i].emplace_back(i+1);
    }
    int srcVertex = 2;
    int destVertex = 32;
    while (n)
    {
        if (n & 1)
        {
            dag[srcVertex].emplace_back(destVertex);
        }
        srcVertex++;
        destVertex += 2;
        n /= 2;
    }
    for (int i=1; i <= maksymalnyNumerWierzcholka; i++)
    {
        while (dag[i].size() < 2) dag[i].push_back(-1);
    }
    return dag;
}

int main() {
    int n;
    scanf("%d", &n);
    vector<vector<int> > res = solve(n);
    int vertices = res.size() - 1;
    printf("%d\n", res.size() - 1);
    for (int i=1; i <= vertices; i++)
    {
        //printf("%d: ", i);
        for (auto v : res[i])
        {
            printf("%d ", v);
        }
        printf("\n");
    }
    return 0;
}