1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <bits/stdc++.h>
using namespace std;
int m,n,i;
vector<int> g[111];
int main() {
  scanf("%d",&m);
  g[n=1].push_back(0);
  for (i=30; i>=0; --i) if ((m>>i)&1) break;
  for (--i; i>=0; --i) {
    g[n+1].push_back(n);
    g[n+2].push_back(n);
    g[n+2].push_back(n+1);
    n+=2;
    if ((m>>i)&1) {
      g[n+1].push_back(n);
      g[++n].push_back(0);
    }
  }
  ++n;
  printf("%d\n",n);
  for (i=n-1; i>=0; i--) printf("%d %d\n",(g[i].empty()?-1:(n-g[i][0])),((g[i].size()<2)?-1:(n-g[i][1])));
  return 0;
}