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
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
//78 dla k=562298878

#include <bits/stdc++.h>
using namespace std;
 
const int inf = 1000000001;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define EACH(it, cont) for (auto &it : cont)
#define FOR(i, b, e)  for (int i = (b); i <= (e); ++i)
#define FORD(i, b, e) for (int i = (b); i >= (e); --i)

#define dump     fancy_dumper::DumpFirst<&std::cerr>(),
#define say      fancy_dumper::DumpFirst<&std::cout>(),
#define $dump    fancy_dumper::Dumper<&std::cerr>
#define $say     fancy_dumper::Dumper<&std::cout>
#define $(x) #x, fancy_dumper::ToggleSeparator(), (x),\
				 fancy_dumper::ToggleSeparator()
 
namespace fancy_dumper {
 
struct ToggleSeparator { };
 
template<std::ostream *Out>
struct DumpFirst { };
 
template<std::ostream *Out>
struct Dumper {
	static void *&last() {
		static void *p;
		return p;
	}
	static const char *&separator() {
		static const char *s = " ";
		return s;
	}
	static const char *&separatorNewLine() {
		static const char *s = "\n";
		return s;
	}
	static const char *&unseparator() {
		static const char *s = "=";
		return s;
	}
	Dumper() {
		last() = this;
	}
	~Dumper() {
		if (this == last()) {
			*Out << separatorNewLine();
			last() = 0;
		}
	}
	Dumper operator, (ToggleSeparator) {
		std::swap(separator(), unseparator());
		return Dumper();
	}
};
 
template<std::ostream *Out, class T>
Dumper<Out> operator,(Dumper<Out>, const T &e) {
	*Out << Dumper<Out>::separator() << e;
	return Dumper<Out>();
}
 
template<std::ostream *Out, class T>
Dumper<Out> operator, (DumpFirst<Out>, const T &e) {
	*Out << e;
	return Dumper<Out>();
}
 
}
 
template<class T, class Y>
std::ostream &operator<< (std::ostream &o, const std::pair<T, Y> &p) {
	return o << p.first << ' ' << p.second;
}
 
template<class T>
std::ostream &operator<< (std::ostream &o, const std::vector<T> &v) {
	bool isBegin = true;
	EACH (e, v) {
		if (!isBegin) { o << ' '; }
		isBegin = false;
		o << e;
	}
	return o;
}
 
template<class T>
std::ostream &operator<< (std::ostream &o, const std::set<T> &v) {
	bool isBegin = true;
	EACH (e, v) {
		if (!isBegin) { o << ' '; }
		isBegin = false;
		o << e;
	}
	return o;
}
 
template<class T>
std::ostream &operator,(std::ostream &o, const T &t) {
	return o << t;
}
 
struct StdinReader {
	StdinReader() { std::ios::sync_with_stdio(0); }
} stdinReader;
#define get stdinReader,
 
template<class T> StdinReader &operator, (StdinReader &sr, T &t) { std::cin >> t; return sr; }
template<class T> StdinReader &operator, (StdinReader &sr, std::vector<T> &v) { EACH (x, v) sr, x; return sr; }
template<class T, class U> StdinReader &operator, (StdinReader &sr, std::pair<T, U> &p) { return sr, p.first, p.second; }
 
template <class T, class U> bool remin(T &a, const U &b) { return b < a ? a = b, true : false; }
template <class T, class U> bool remax(T &a, const U &b) { return b > a ? a = b, true : false; }

// code starts here

struct Ans {
	vector<pair<int,int>> g;
	Ans(int q) {
		g.push_back({-1,-1});
		f(q);
		replace100();
	}

	void f(int q) {
		if (q == 1) {
			g.back() = {100, -1};
			g.push_back({-1, -1});
		}
		while (q > 1) {
			if (q % 7 == 0) {
				int b = size(g)+1;
				int v = b+1;
				int u = v + 1;
				int w = v + 2;
				int x = v + 3;
				int z = v + 4;
				g.back() = {b, z};
				g.push_back({v, u});
				g.push_back({w, x});
				g.push_back({w, z});
				g.push_back({x, z});
				g.push_back({-1, z});
				g.push_back({-1, -1});
				q /= 7;
			} else if (q % 11 == 0) {
				int v2 = size(g)+1;
				int v3 = v2 + 1;
				int v4 = v2 + 2;
				int v5 = v2 + 3;
				int v6 = v2 + 4;
				int v8 = v2 + 5;
				int v9 = v2 + 6;
				int v11= v2 + 7;
				g.back() = {v2, v11}; // v1
				g.push_back({v3, v8}); // v2
				g.push_back({v4, v5}); // v3
				g.push_back({v6, v8});
				g.push_back({v6, v8});
				g.push_back({v8, -1});
				g.push_back({v9, v11});
				g.push_back({v11, -1});
				g.push_back({-1, -1});
				q /= 11;
			} else if (q % 13 == 0) {
				int v2 = size(g)+1;
				int v3 = v2 + 1;
				int v4 = v2 + 2;
				int v5 = v2 + 3;
				int v6 = v2 + 4;
				int v7 = v2 + 5;
				int v8 = v2 + 6;
				int v9 = v2 + 7;
				g.back() = {v2, v9}; // v1
				g.push_back({v5, v8}); // v2
				g.push_back({v6, v9}); // v3
				g.push_back({v6, v7});
				g.push_back({v4, v3});
				g.push_back({v7, v9});
				g.push_back({v9, -1});
				g.push_back({v3, v4});
				g.push_back({-1, -1});
				q /= 13;
			} else if (q % 6 == 0) {
				int v = size(g)+1;
				int u = v + 1;
				int w = v + 2;
				int x = v + 3;
				int z = v + 4;
				g.back() = {v, u};
				g.push_back({w, x});
				g.push_back({w, z});
				g.push_back({x, z});
				g.push_back({-1, z});
				g.push_back({-1, -1});
				q /= 6;
			} else if (q % 5 == 0) {
				int b = size(g)+1;
				int v = b+1;
				int u = v + 1;
				int w = v + 2;
				int y = v + 3;
				g.back() = {b, y};
				g.push_back({v, u});
				g.push_back({w, y});
				g.push_back({w, y});
				g.push_back({y, -1});
				g.push_back({-1, -1});
				q /= 5;
			} else if (q % 4 == 0) {
				int v = size(g)+1;
				int u = v + 1;
				int w = v + 2;
				int y = v + 3;
				g.back() = {v, u};
				g.push_back({w, y});
				g.push_back({w, y});
				g.push_back({y, -1});
				g.push_back({-1, -1});
				q /= 4;
			} else if (q % 3 == 0) {
				int v = size(g)+1;
				int w = v + 1;
				int y = v + 2;
				g.back() = {v, y};
				g.push_back({w, y});
				g.push_back({-1, y});
				g.push_back({-1, -1});
				q /= 3;
			} else if (q & 1)  {
				int v = size(g)+1;
				if (--q) {
					g.back() = {100, v};
				} else {
					g.back() = {100, -1};
				}
				g.push_back({-1, -1});
			} else {
				int v = size(g)+1;
				int w = v + 1;
				g.back() = {v, w};
				g.push_back({w, -1});
				g.push_back({-1, -1});
				q /= 2;
			}
		}
	}

	void replace100() {
		EACH (v, g) {
			if (v.first == 100) {
				v.first = size(g);
			}
		}
	}

	void print() {
		say size(g), g;
	}

	void dot() {
		// usage example: ./dag <<< 21 | dot -Tpng > out.png
		say "digraph", size(g), '{';
		REP (i, (int)size(g)) {
			if (g[i].first != -1) say i+1, "->", g[i].first, ';';
			if (g[i].second != -1) say i+1, "->", g[i].second, ';';
		}
		say '}';
	}
};

int check() {
	int mx = 0;
	for (int i = 500000001; i <= 1000000000; i++) {
		Ans a(i);
		remax(mx, (int) a.g.size());
		if (mx > 100) {
			dump "fail", $(i), $(mx);
			return mx;
		}
		if (i % 10000 == 0) {
			dump "done", $(i), $(mx);
			mx = 0;
		}
	}
	return 0;
}

int main() {
	int q;
	get q;
	Ans a(q);
	a.print();
	//~ a.dot();
	//~ return check();
}