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
#include<bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
using ll=long long;
const int S=100;
vector<int>dag[S+6];
int n;
void add(int j)
{
    int id=2;
    for(int i=1;i<=j;i++)
    {
        dag[id].push_back(id+2);
        id+=2;
    }
    n=id+1;
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int k;cin>>k;
    bool check=0;
    int sg;
    if(k==1)
    {
        cout<<2<<"\n";
        cout<<2<<" "<<-1<<"\n";
        cout<<-1<<" "<<-1;
        return 0;
    }
    for(int i=30;i>=0;i--)
    {
        int m=k&(1<<i);
        if(m==0)continue;
        if(!check)
        {
            if(i==0)break;
            sg=i;
            add(i);
            check=1;
            continue;
        }
        int id=2+2*i+1;
        if(i==0)id=1;
        dag[id].push_back(n);
    }
    for(int i=1;i<n;i++)dag[i].push_back(i+1);
    dag[n].push_back(-1);
    dag[n].push_back(-1);
    //return 0;
    cout<<n<<"\n";
    for(int i=1;i<=n;i++)
    {
        for(auto it:dag[i])cout<<it<<" ";
        if(dag[i].size()<2)cout<<-1;
        cout<<"\n";
    }
}