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
79
80
81
82
83
84
85
86
87
88
89
90
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
//                                                                  .....
int fib[44]={1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309, 3524578, 5702887, 9227465, 14930352, 24157817, 39088169, 63245986, 102334155, 165580141, 267914296, 433494437, 701408733, 1134903170};
int qua[44]={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};


vector<int> rozklad(int a){
    vector<int> result;
    for(int i = 43; i>=0; i--){
        if(a>=fib[i]){
            result.push_back(fib[i]);
            a-=fib[i];
        }
    }
    return result;
}

/*int lastOne(vector<int> fibDec){
    int sum=0;
    for(int i = 0; i<fibDec.size(); i++){
        for(int j = 0; j<18;j++){
            if(fib[j]==fibDec[i])
                sum+=qua[j];
        }
    }
    //if(fibDec.size()>1)
        sum+=1;
    return sum+fibDec.size()-1;
}*/

inline int fibQuantity(int fibNum){
    for(int i = 0; i<44; i++)
        if(fib[i]==fibNum)
            return qua[i];
}

int lastOne(vector<int> fibDec){
    int suma=fibDec.size();
    for(int i =0;i<fibDec.size();i++){
        suma+=fibQuantity(fibDec[i]);
    }
    return suma;
}

vector<pair<int,int>> preparePart(int startPoint, int fibNum, int ending){
    int vertices = fibQuantity(fibNum);
    vector<pair<int,int>> result;
    for(int i=0;i<vertices-1;i++){
        pair<int,int> p;
        if(i==vertices-2)
            p=make_pair(i+1+startPoint,-1);
        else
            p=make_pair(i+1+startPoint,i+2+startPoint);
        result.push_back(p);
    }
    pair<int,int> last = make_pair(ending,-1);
    result.push_back(last);
    return result;
}

int main(){

    int n=3;
    scanf("%d",&n);

    vector<int> fibDec=rozklad(n);
    int ending = lastOne(fibDec);//fibQuantity(fibDec[0])+1;
    //cout<<lastOne(fibDec);
    int startPoint=1;
    vector<pair<int,int>> graf;
    for(int i = 0; i<fibDec.size();i++){
        vector<pair<int,int>> temp = preparePart(startPoint+1,fibDec[i],ending);
        int nextHook=((i==fibDec.size()-1)? -1: startPoint+temp.size()+1);
        graf.push_back(make_pair(startPoint+1,nextHook));
        graf.insert(graf.end(), temp.begin(), temp.end());
        startPoint+=temp.size()+1;
    }
    cout<<graf.size()<<endl;
    graf[graf.size()-1]=make_pair(-1,-1);
    for(int i = 0; i<graf.size();i++){
        cout<<graf[i].first<<" "<<graf[i].second<<endl;
    }


    return 0;
}