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
74
75
76
77
78
#include <iostream>
#include <vector>
#include <memory>
#include <bitset>
#include <tuple>

std::vector<std::pair<int, int>> dag(int degree)
{
    std::vector<std::pair<int, int>> result;

    for (int i = 0; i < degree; ++i)
    {
        result.push_back({16 + i, 17 + i});
    }

    return result;
}

void solve(int k)
{
    std::bitset<32> bits(k);

    int degree = 0;
    for (int i = bits.size() - 1; i >= 0; --i)
    {
        if (bits[i])
        {
            degree = i;
            break;
        }
    }
    int n = 33+2*degree;
    std::cout << n << std::endl;
    for (int i = 1; i < 16; ++i)
    {
        std::cout << 2 * i << " " << 2 * i + 1 << std::endl;
    }
    bool parz = degree % 2 == 0;

    for (int i = 0; i < bits.size(); i += 2)
    {
        if (bits[i])
            std::cout << 32 + 2*i<< " ";
        else
            std::cout << "-1 ";
        if (bits[i + 1])
            std::cout << 32 + 2*(i+1);
        else
            std::cout << "-1";

        std::cout << std::endl;
    }
    if (degree == 0)
    {
        std::cout << "-1 " << n << std::endl;
        std::cout << "-1 -1" << std::endl;
        return;
    }
    std::cout << "-1 " << n << std::endl;
    std::cout << "-1 " << n << std::endl;

    for (int i = 0; i<degree-1; ++i)
    {
        std::cout << 32 + 2*i << " " << 33 + 2*i << std::endl; 
        std::cout << 32 + 2*i << " " << 33 + 2*i << std::endl; 
    }

    std::cout << n-2 << " " << n-3 << std::endl; 
    std::cout << "-1 -1" << std::endl;
}

int main()
{
    int k;
    std::cin >> k;
    solve(k);
    return 0;
}