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
#include<cstdio>
#include<algorithm>

int k, n, koncowka;
int bin[35];
int max_potega;

int main () {
  scanf("%d", &k);
  
  if (k == 1) {
	  printf("2\n2 -1\n-1 -1\n");
	  return 0;
  }
  
  while(k > 0) {
	bin[max_potega] = k % 2;
	k /= 2;
	max_potega++;
  }
  max_potega--;
  
  n = max_potega*3 + 3;
  koncowka = n - 2;
  
  printf("%d\n", max_potega*3 + 3);
  printf("2 -1\n");
  printf("3 -1\n");
  for (int i = 0; i < max_potega; i++) {
	printf("%d %d\n", i*3 + 4, i*3 + 5);
	printf("%d %d\n", i*3 + 6, bin[i] == 1 ? (i == (max_potega - 1) ? n - 1 :  n) : -1);
	printf("%d %d\n", i*3 + 6, -1);
  }
  printf("-1 -1\n");
  
  

  return 0;
}