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
#include <bits/stdc++.h>

using namespace std;

int k;

int next = 63;

vector<int> adj[205];

int main() {
    scanf("%d", &k);
    puts("100");
    for(int i = 1; i < 30; i++) {
        int a1 = (i + 1) << 1 | 0;
        int a2 = (i + 1) << 1 | 1;
        
        adj[a1].push_back(a1 - 1);
        adj[a1].push_back(a1 - 2);

        adj[a2].push_back(a1 - 1);
        adj[a2].push_back(a1 - 2);
    }

    adj[2].push_back(100);
    adj[3].push_back(100);
    
    int nx_node = 63;
    vector<int> nodes;
    for(int i = 0; i < 30; i++) {
        if(k & (1 << i)) {
            nodes.push_back((i + 1) << 1 | 0);
        }
    }
     
    while(nodes.size() > 2) {
        int a = nodes.back(); nodes.pop_back();
        int b = nodes.back(); nodes.pop_back();
        adj[nx_node].push_back(a);
        adj[nx_node].push_back(b);
        nodes.push_back(nx_node);
        nx_node++;
    }

    adj[1] = nodes;

#ifdef LOCAL 
    for(int i = 1; i <= 100; i++) {
        for(int j : adj[i])
            printf("%d %d\n", i, j);
    }
    
    return 0;
#endif

    for(int i = 1; i <= 100; i++) {
        for(int j = 0; j < 2; j++) {
            if(j < (int) adj[i].size()) {
                printf("%d ", adj[i][j]);
            } else {
                printf("-1 ");
            } 
        }
        puts("");
    }
}