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
#include <bits/stdc++.h>
#define qio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) cerr<<#x<<" "<<x<<endl
#define ll long long 
#define st first
#define nd second
using namespace std;

int k, n, nex;
vector <int> V;
pair <int, int> P[105];
void zbuduj() {
	ll temp = 1;
	while (temp <= (ll)pow(2, 31)) {
		P[n].st = n + 1;
		P[n].nd = n + 2;
		P[n + 1].st = n + 2;
		n += 2;
		temp *= 2;
	}
}
int main()
{
	qio;
	cin >> k;
	while (k > 0) {
		V.push_back(k % 2);
		k /= 2;
	}
	n = 1;
	for (int i = 1; i <= 100; i++) {
		P[i] = { -1,-1 };
	}
	zbuduj();
	for (int i = 0; i < V.size(); i++) {
		if (V[i] == 1) P[(i + 1) * 2].nd = n + 1;
	}
	cout << n + 1 << endl;
	for (int i = 1; i <= n + 1; i++) {
		cout << P[i].st << " " << P[i].nd << endl;
	}
}